diff options
author | Ade Lee <alee@redhat.com> | 2012-01-11 12:57:53 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2012-01-11 13:49:04 -0500 |
commit | 10cfe7756e967ac91c66d33b392aeab9cf3780fb (patch) | |
tree | d5ac9b58442265d2ce5ef60e31f041ddacba1b4f /pki/base/common/src/com/netscape/cmscore/dbs | |
parent | edcb24f65cc3700e75d0a1d14dc2483f210b0ee4 (diff) | |
download | pki-10cfe7756e967ac91c66d33b392aeab9cf3780fb.tar.gz pki-10cfe7756e967ac91c66d33b392aeab9cf3780fb.tar.xz pki-10cfe7756e967ac91c66d33b392aeab9cf3780fb.zip |
Formatting (no line wrap in comments or code)
Diffstat (limited to 'pki/base/common/src/com/netscape/cmscore/dbs')
40 files changed, 1332 insertions, 1413 deletions
diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/BigIntegerMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/BigIntegerMapper.java index 7cd563f99..3fa613198 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/BigIntegerMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/BigIntegerMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.math.BigInteger; import java.util.Enumeration; import java.util.Vector; @@ -29,14 +28,13 @@ import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; - /** * A class represents ann attribute mapper that maps * a Java BigInteger object into LDAP attribute, * and vice versa. - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class BigIntegerMapper implements IDBAttrMapper { @@ -61,10 +59,10 @@ public class BigIntegerMapper implements IDBAttrMapper { /** * Maps object into ldap attribute set. */ - public void mapObjectToLDAPAttributeSet(IDBObj parent, - String name, Object obj, LDAPAttributeSet attrs) - throws EBaseException { - attrs.add(new LDAPAttribute(mLdapName, + public void mapObjectToLDAPAttributeSet(IDBObj parent, + String name, Object obj, LDAPAttributeSet attrs) + throws EBaseException { + attrs.add(new LDAPAttribute(mLdapName, BigIntegerToDB((BigInteger) obj))); } @@ -72,8 +70,8 @@ public class BigIntegerMapper implements IDBAttrMapper { * Maps LDAP attributes into object, and put the object * into 'parent'. */ - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { LDAPAttribute attr = attrs.getAttribute(mLdapName); if (attr == null) @@ -85,8 +83,8 @@ public class BigIntegerMapper implements IDBAttrMapper { /** * Maps search filters into LDAP search filter. */ - public String mapSearchFilter(String name, String op, - String value) throws EBaseException { + public String mapSearchFilter(String name, String op, + String value) throws EBaseException { String v = null; try { diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/ByteArrayMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/ByteArrayMapper.java index b8e5b73dd..a51905c79 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/ByteArrayMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/ByteArrayMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Enumeration; import java.util.Vector; @@ -29,14 +28,13 @@ import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; - /** * A class represents ann attribute mapper that maps * a Java byte array object into LDAP attribute, * and vice versa. - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class ByteArrayMapper implements IDBAttrMapper { @@ -61,16 +59,16 @@ public class ByteArrayMapper implements IDBAttrMapper { /** * Maps object to ldap attribute set. */ - public void mapObjectToLDAPAttributeSet(IDBObj parent, - String name, Object obj, LDAPAttributeSet attrs) - throws EBaseException { + public void mapObjectToLDAPAttributeSet(IDBObj parent, + String name, Object obj, LDAPAttributeSet attrs) + throws EBaseException { byte data[] = (byte[]) obj; if (data == null) { CMS.debug("ByteArrayMapper:mapObjectToLDAPAttributeSet " + name + - " size=0"); + " size=0"); } else { CMS.debug("ByteArrayMapper:mapObjectToLDAPAttributeSet " + name + - " size=" + data.length); + " size=" + data.length); } attrs.add(new LDAPAttribute(mLdapName, data)); } @@ -79,8 +77,8 @@ public class ByteArrayMapper implements IDBAttrMapper { * Maps LDAP attributes into object, and put the object * into 'parent'. */ - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { LDAPAttribute attr = attrs.getAttribute(mLdapName); if (attr == null) @@ -91,8 +89,8 @@ public class ByteArrayMapper implements IDBAttrMapper { /** * Maps search filters into LDAP search filter. */ - public String mapSearchFilter(String name, String op, - String value) throws EBaseException { + public String mapSearchFilter(String name, String op, + String value) throws EBaseException { return mLdapName + op + value; } } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/CRLDBSchema.java b/pki/base/common/src/com/netscape/cmscore/dbs/CRLDBSchema.java index 58342a557..253bd81e0 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/CRLDBSchema.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/CRLDBSchema.java @@ -17,14 +17,11 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - - - /** * A class represents a collection of schema information * for CRL. * <P> - * + * * @author thomask * @version $Revision$, $Date$ */ 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 ea110d1c9..df44797f1 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/CRLIssuingPointRecord.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/CRLIssuingPointRecord.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.math.BigInteger; import java.util.Date; import java.util.Enumeration; @@ -29,11 +28,10 @@ import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.IDBObj; import com.netscape.certsrv.dbs.crldb.ICRLIssuingPointRecord; - /** * A class represents a CRL issuing point record. * <P> - * + * * @author thomask * @version $Revision$, $Date$ */ @@ -43,8 +41,8 @@ public class CRLIssuingPointRecord implements ICRLIssuingPointRecord, IDBObj { * */ private static final long serialVersionUID = 400565044343905267L; - protected String mId = null; // internal unique id - protected BigInteger mCRLNumber = null; // CRL number + protected String mId = null; // internal unique id + protected BigInteger mCRLNumber = null; // CRL number protected Long mCRLSize = null; protected Date mThisUpdate = null; protected Date mNextUpdate = null; @@ -87,8 +85,8 @@ public class CRLIssuingPointRecord implements ICRLIssuingPointRecord, IDBObj { /** * Constructs a CRLIssuingPointRecord */ - public CRLIssuingPointRecord(String id, BigInteger crlNumber, Long crlSize, - Date thisUpdate, Date nextUpdate) { + public CRLIssuingPointRecord(String id, BigInteger crlNumber, Long crlSize, + Date thisUpdate, Date nextUpdate) { mId = id; mCRLNumber = crlNumber; mCRLSize = crlSize; @@ -106,9 +104,9 @@ public class CRLIssuingPointRecord implements ICRLIssuingPointRecord, IDBObj { /** * Constructs a CRLIssuingPointRecord */ - public CRLIssuingPointRecord(String id, BigInteger crlNumber, Long crlSize, - Date thisUpdate, Date nextUpdate, BigInteger deltaCRLNumber, Long deltaCRLSize, - Hashtable revokedCerts, Hashtable unrevokedCerts, Hashtable expiredCerts) { + public CRLIssuingPointRecord(String id, BigInteger crlNumber, Long crlSize, + Date thisUpdate, Date nextUpdate, BigInteger deltaCRLNumber, Long deltaCRLSize, + Hashtable revokedCerts, Hashtable unrevokedCerts, Hashtable expiredCerts) { mId = id; mCRLNumber = crlNumber; mCRLSize = crlSize; 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 ba3ed5a7f..5cf7ecbc2 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/CRLRepository.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/CRLRepository.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.math.BigInteger; import java.util.Date; import java.util.Hashtable; @@ -36,10 +35,10 @@ import com.netscape.certsrv.dbs.crldb.ICRLIssuingPointRecord; import com.netscape.certsrv.dbs.crldb.ICRLRepository; /** - * A class represents a CRL repository. It stores all the + * A class represents a CRL repository. It stores all the * CRL issuing points. * <P> - * + * * @author thomask * @version $Revision$, $Date$ */ @@ -52,8 +51,8 @@ public class CRLRepository extends Repository implements ICRLRepository { /** * Constructs a CRL repository. */ - public CRLRepository(IDBSubsystem dbService, int increment, String baseDN) - throws EDBException { + public CRLRepository(IDBSubsystem dbService, int increment, String baseDN) + throws EDBException { super(dbService, increment, baseDN); mBaseDN = baseDN; mDBService = dbService; @@ -61,22 +60,22 @@ public class CRLRepository extends Repository implements ICRLRepository { IDBRegistry reg = dbService.getRegistry(); /** - String crlRecordOC[] = new String[1]; - crlRecordOC[0] = Schema.LDAP_OC_CRL_RECORD; - reg.registerObjectClass(CRLIssuingPointRecord.class.getName(), - crlRecordOC); - reg.registerAttribute(ICRLIssuingPointRecord.ATTR_ID, new - StringMapper(Schema.LDAP_ATTR_CRL_ID)); - reg.registerAttribute(ICRLIssuingPointRecord.ATTR_CRL_NUMBER, new - BigIntegerMapper(Schema.LDAP_ATTR_CRL_NUMBER)); - reg.registerAttribute(ICRLIssuingPointRecord.ATTR_CRL_SIZE, new - LongMapper(Schema.LDAP_ATTR_CRL_SIZE)); - reg.registerAttribute(ICRLIssuingPointRecord.ATTR_THIS_UPDATE, new - DateMapper(Schema.LDAP_ATTR_THIS_UPDATE)); - reg.registerAttribute(ICRLIssuingPointRecord.ATTR_NEXT_UPDATE, new - DateMapper(Schema.LDAP_ATTR_NEXT_UPDATE)); - reg.registerAttribute(ICRLIssuingPointRecord.ATTR_CRL, new - ByteArrayMapper(Schema.LDAP_ATTR_CRL)); + * String crlRecordOC[] = new String[1]; + * crlRecordOC[0] = Schema.LDAP_OC_CRL_RECORD; + * reg.registerObjectClass(CRLIssuingPointRecord.class.getName(), + * crlRecordOC); + * reg.registerAttribute(ICRLIssuingPointRecord.ATTR_ID, new + * StringMapper(Schema.LDAP_ATTR_CRL_ID)); + * reg.registerAttribute(ICRLIssuingPointRecord.ATTR_CRL_NUMBER, new + * BigIntegerMapper(Schema.LDAP_ATTR_CRL_NUMBER)); + * reg.registerAttribute(ICRLIssuingPointRecord.ATTR_CRL_SIZE, new + * LongMapper(Schema.LDAP_ATTR_CRL_SIZE)); + * reg.registerAttribute(ICRLIssuingPointRecord.ATTR_THIS_UPDATE, new + * DateMapper(Schema.LDAP_ATTR_THIS_UPDATE)); + * reg.registerAttribute(ICRLIssuingPointRecord.ATTR_NEXT_UPDATE, new + * DateMapper(Schema.LDAP_ATTR_NEXT_UPDATE)); + * reg.registerAttribute(ICRLIssuingPointRecord.ATTR_CRL, new + * ByteArrayMapper(Schema.LDAP_ATTR_CRL)); **/ } @@ -97,24 +96,23 @@ public class CRLRepository extends Repository implements ICRLRepository { /** * Removes all objects with this repository. */ - public void removeAllObjects() throws EBaseException - { + public void removeAllObjects() throws EBaseException { } /** * Adds CRL issuing points. */ public void addCRLIssuingPointRecord(ICRLIssuingPointRecord rec) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); try { String name = mLdapCRLIssuingPointName + "=" + - ((CRLIssuingPointRecord) rec).getId().toString() + "," + getDN(); + ((CRLIssuingPointRecord) rec).getId().toString() + "," + getDN(); s.add(name, rec); - } finally { - if (s != null) + } finally { + if (s != null) s.close(); } } @@ -125,21 +123,21 @@ public class CRLRepository extends Repository implements ICRLRepository { public Vector getIssuingPointsNames() throws EBaseException { IDBSSession s = mDBService.createSession(); try { - String[] attrs = {ICRLIssuingPointRecord.ATTR_ID, "objectclass"}; + String[] attrs = { ICRLIssuingPointRecord.ATTR_ID, "objectclass" }; String filter = "objectclass=" + CMS.getCRLIssuingPointRecordName(); IDBSearchResults res = s.search(getDN(), filter, attrs); Vector v = new Vector(); while (res.hasMoreElements()) { - ICRLIssuingPointRecord nextelement = - (ICRLIssuingPointRecord)res.nextElement(); + ICRLIssuingPointRecord nextelement = + (ICRLIssuingPointRecord) res.nextElement(); CMS.debug("CRLRepository getIssuingPointsNames(): name = " - +nextelement.getId()); + + nextelement.getId()); v.addElement(nextelement.getId()); } return v; } finally { - if (s != null) + if (s != null) s.close(); } } @@ -148,19 +146,20 @@ public class CRLRepository extends Repository implements ICRLRepository { * Reads issuing point record. */ public ICRLIssuingPointRecord readCRLIssuingPointRecord(String id) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); CRLIssuingPointRecord rec = null; try { String name = mLdapCRLIssuingPointName + "=" + id + - "," + getDN(); + "," + getDN(); if (s != null) { rec = (CRLIssuingPointRecord) s.read(name); } - } finally { - if (s != null) s.close(); + } finally { + if (s != null) + s.close(); } return rec; } @@ -169,31 +168,35 @@ public class CRLRepository extends Repository implements ICRLRepository { * deletes issuing point record. */ public void deleteCRLIssuingPointRecord(String id) - throws EBaseException { + throws EBaseException { IDBSSession s = null; try { s = mDBService.createSession(); String name = mLdapCRLIssuingPointName + "=" + id + - "," + getDN(); + "," + getDN(); - if (s != null) s.delete(name); + if (s != null) + s.delete(name); } finally { - if (s != null) s.close(); + if (s != null) + s.close(); } } - public void modifyCRLIssuingPointRecord(String id, - ModificationSet mods) throws EBaseException { + public void modifyCRLIssuingPointRecord(String id, + ModificationSet mods) throws EBaseException { IDBSSession s = mDBService.createSession(); try { String name = mLdapCRLIssuingPointName + "=" + id + - "," + getDN(); + "," + getDN(); - if (s != null) s.modify(name, mods); - } finally { - if (s != null) s.close(); + if (s != null) + s.modify(name, mods); + } finally { + if (s != null) + s.close(); } } @@ -201,24 +204,24 @@ public class CRLRepository extends Repository implements ICRLRepository { * Updates CRL issuing point record. */ public void updateCRLIssuingPointRecord(String id, byte[] newCRL, - Date thisUpdate, Date nextUpdate, BigInteger crlNumber, Long crlSize) - throws EBaseException { + Date thisUpdate, Date nextUpdate, BigInteger crlNumber, Long crlSize) + throws EBaseException { ModificationSet mods = new ModificationSet(); if (newCRL != null) { - mods.add(ICRLIssuingPointRecord.ATTR_CRL, - Modification.MOD_REPLACE, newCRL); + mods.add(ICRLIssuingPointRecord.ATTR_CRL, + Modification.MOD_REPLACE, newCRL); } if (nextUpdate != null) { - mods.add(ICRLIssuingPointRecord.ATTR_NEXT_UPDATE, - Modification.MOD_REPLACE, nextUpdate); + mods.add(ICRLIssuingPointRecord.ATTR_NEXT_UPDATE, + Modification.MOD_REPLACE, nextUpdate); } - mods.add(ICRLIssuingPointRecord.ATTR_THIS_UPDATE, - Modification.MOD_REPLACE, thisUpdate); - mods.add(ICRLIssuingPointRecord.ATTR_CRL_NUMBER, - Modification.MOD_REPLACE, crlNumber); - mods.add(ICRLIssuingPointRecord.ATTR_CRL_SIZE, - Modification.MOD_REPLACE, crlSize); + mods.add(ICRLIssuingPointRecord.ATTR_THIS_UPDATE, + Modification.MOD_REPLACE, thisUpdate); + mods.add(ICRLIssuingPointRecord.ATTR_CRL_NUMBER, + Modification.MOD_REPLACE, crlNumber); + mods.add(ICRLIssuingPointRecord.ATTR_CRL_SIZE, + Modification.MOD_REPLACE, crlSize); modifyCRLIssuingPointRecord(id, mods); } @@ -226,40 +229,40 @@ public class CRLRepository extends Repository implements ICRLRepository { * Updates CRL issuing point record. */ public void updateCRLIssuingPointRecord(String id, byte[] newCRL, - Date thisUpdate, Date nextUpdate, BigInteger crlNumber, Long crlSize, - Hashtable revokedCerts, Hashtable unrevokedCerts, Hashtable expiredCerts) - throws EBaseException { + Date thisUpdate, Date nextUpdate, BigInteger crlNumber, Long crlSize, + Hashtable revokedCerts, Hashtable unrevokedCerts, Hashtable expiredCerts) + throws EBaseException { ModificationSet mods = new ModificationSet(); if (newCRL != null) { - mods.add(ICRLIssuingPointRecord.ATTR_CRL, - Modification.MOD_REPLACE, newCRL); + mods.add(ICRLIssuingPointRecord.ATTR_CRL, + Modification.MOD_REPLACE, newCRL); } if (nextUpdate != null) { - mods.add(ICRLIssuingPointRecord.ATTR_NEXT_UPDATE, - Modification.MOD_REPLACE, nextUpdate); + mods.add(ICRLIssuingPointRecord.ATTR_NEXT_UPDATE, + Modification.MOD_REPLACE, nextUpdate); } - mods.add(ICRLIssuingPointRecord.ATTR_THIS_UPDATE, - Modification.MOD_REPLACE, thisUpdate); - mods.add(ICRLIssuingPointRecord.ATTR_CRL_NUMBER, - Modification.MOD_REPLACE, crlNumber); - mods.add(ICRLIssuingPointRecord.ATTR_CRL_SIZE, - Modification.MOD_REPLACE, crlSize); + mods.add(ICRLIssuingPointRecord.ATTR_THIS_UPDATE, + Modification.MOD_REPLACE, thisUpdate); + mods.add(ICRLIssuingPointRecord.ATTR_CRL_NUMBER, + Modification.MOD_REPLACE, crlNumber); + mods.add(ICRLIssuingPointRecord.ATTR_CRL_SIZE, + Modification.MOD_REPLACE, crlSize); if (revokedCerts != null) { - mods.add(ICRLIssuingPointRecord.ATTR_REVOKED_CERTS, - Modification.MOD_REPLACE, revokedCerts); + mods.add(ICRLIssuingPointRecord.ATTR_REVOKED_CERTS, + Modification.MOD_REPLACE, revokedCerts); } if (unrevokedCerts != null) { - mods.add(ICRLIssuingPointRecord.ATTR_UNREVOKED_CERTS, - Modification.MOD_REPLACE, unrevokedCerts); + mods.add(ICRLIssuingPointRecord.ATTR_UNREVOKED_CERTS, + Modification.MOD_REPLACE, unrevokedCerts); } if (expiredCerts != null) { - mods.add(ICRLIssuingPointRecord.ATTR_EXPIRED_CERTS, - Modification.MOD_REPLACE, expiredCerts); + mods.add(ICRLIssuingPointRecord.ATTR_EXPIRED_CERTS, + Modification.MOD_REPLACE, expiredCerts); } if (revokedCerts != null || unrevokedCerts != null) { mods.add(ICRLIssuingPointRecord.ATTR_FIRST_UNSAVED, - Modification.MOD_REPLACE, ICRLIssuingPointRecord.CLEAN_CACHE); + Modification.MOD_REPLACE, ICRLIssuingPointRecord.CLEAN_CACHE); } modifyCRLIssuingPointRecord(id, mods); } @@ -268,16 +271,16 @@ 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) - throws EBaseException { + Hashtable unrevokedCerts) + throws EBaseException { ModificationSet mods = new ModificationSet(); - mods.add(ICRLIssuingPointRecord.ATTR_REVOKED_CERTS, - Modification.MOD_REPLACE, revokedCerts); - mods.add(ICRLIssuingPointRecord.ATTR_UNREVOKED_CERTS, - Modification.MOD_REPLACE, unrevokedCerts); + mods.add(ICRLIssuingPointRecord.ATTR_REVOKED_CERTS, + Modification.MOD_REPLACE, revokedCerts); + mods.add(ICRLIssuingPointRecord.ATTR_UNREVOKED_CERTS, + Modification.MOD_REPLACE, unrevokedCerts); mods.add(ICRLIssuingPointRecord.ATTR_FIRST_UNSAVED, - Modification.MOD_REPLACE, ICRLIssuingPointRecord.CLEAN_CACHE); + Modification.MOD_REPLACE, ICRLIssuingPointRecord.CLEAN_CACHE); modifyCRLIssuingPointRecord(id, mods); } @@ -285,11 +288,11 @@ public class CRLRepository extends Repository implements ICRLRepository { * Updates CRL issuing point record with recently expired certificates info. */ public void updateExpiredCerts(String id, Hashtable expiredCerts) - throws EBaseException { + throws EBaseException { ModificationSet mods = new ModificationSet(); - mods.add(ICRLIssuingPointRecord.ATTR_EXPIRED_CERTS, - Modification.MOD_REPLACE, expiredCerts); + mods.add(ICRLIssuingPointRecord.ATTR_EXPIRED_CERTS, + Modification.MOD_REPLACE, expiredCerts); modifyCRLIssuingPointRecord(id, mods); } @@ -297,24 +300,24 @@ 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) - throws EBaseException { + Hashtable revokedCerts, + Hashtable unrevokedCerts, + Hashtable expiredCerts) + throws EBaseException { ModificationSet mods = new ModificationSet(); if (crlSize != null) { - mods.add(ICRLIssuingPointRecord.ATTR_CRL_SIZE, - Modification.MOD_REPLACE, crlSize); + mods.add(ICRLIssuingPointRecord.ATTR_CRL_SIZE, + Modification.MOD_REPLACE, crlSize); } mods.add(ICRLIssuingPointRecord.ATTR_REVOKED_CERTS, - Modification.MOD_REPLACE, revokedCerts); + Modification.MOD_REPLACE, revokedCerts); mods.add(ICRLIssuingPointRecord.ATTR_UNREVOKED_CERTS, - Modification.MOD_REPLACE, unrevokedCerts); + Modification.MOD_REPLACE, unrevokedCerts); mods.add(ICRLIssuingPointRecord.ATTR_EXPIRED_CERTS, - Modification.MOD_REPLACE, expiredCerts); + Modification.MOD_REPLACE, expiredCerts); mods.add(ICRLIssuingPointRecord.ATTR_FIRST_UNSAVED, - Modification.MOD_REPLACE, ICRLIssuingPointRecord.CLEAN_CACHE); + Modification.MOD_REPLACE, ICRLIssuingPointRecord.CLEAN_CACHE); modifyCRLIssuingPointRecord(id, mods); } @@ -324,41 +327,41 @@ public class CRLRepository extends Repository implements ICRLRepository { public void updateDeltaCRL(String id, BigInteger deltaCRLNumber, Long deltaCRLSize, Date nextUpdate, byte[] deltaCRL) - throws EBaseException { + throws EBaseException { ModificationSet mods = new ModificationSet(); if (deltaCRLNumber != null) { mods.add(ICRLIssuingPointRecord.ATTR_DELTA_NUMBER, - Modification.MOD_REPLACE, deltaCRLNumber); + Modification.MOD_REPLACE, deltaCRLNumber); } if (deltaCRLSize != null) { - mods.add(ICRLIssuingPointRecord.ATTR_DELTA_SIZE, - Modification.MOD_REPLACE, deltaCRLSize); + mods.add(ICRLIssuingPointRecord.ATTR_DELTA_SIZE, + Modification.MOD_REPLACE, deltaCRLSize); } if (nextUpdate != null) { - mods.add(ICRLIssuingPointRecord.ATTR_NEXT_UPDATE, - Modification.MOD_REPLACE, nextUpdate); + mods.add(ICRLIssuingPointRecord.ATTR_NEXT_UPDATE, + Modification.MOD_REPLACE, nextUpdate); } if (deltaCRL != null) { - mods.add(ICRLIssuingPointRecord.ATTR_DELTA_CRL, - Modification.MOD_REPLACE, deltaCRL); + mods.add(ICRLIssuingPointRecord.ATTR_DELTA_CRL, + Modification.MOD_REPLACE, deltaCRL); } modifyCRLIssuingPointRecord(id, mods); } public void updateFirstUnsaved(String id, String firstUnsaved) - throws EBaseException { + throws EBaseException { ModificationSet mods = new ModificationSet(); if (firstUnsaved != null) { - mods.add(ICRLIssuingPointRecord.ATTR_FIRST_UNSAVED, - Modification.MOD_REPLACE, firstUnsaved); + mods.add(ICRLIssuingPointRecord.ATTR_FIRST_UNSAVED, + Modification.MOD_REPLACE, firstUnsaved); } modifyCRLIssuingPointRecord(id, mods); } - public BigInteger getLastSerialNumberInRange(BigInteger serial_low_bound, BigInteger serial_upper_bound) - throws EBaseException { + public BigInteger getLastSerialNumberInRange(BigInteger serial_low_bound, BigInteger serial_upper_bound) + throws EBaseException { return null; } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/CertDBSchema.java b/pki/base/common/src/com/netscape/cmscore/dbs/CertDBSchema.java index 83164aab5..67b662713 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/CertDBSchema.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/CertDBSchema.java @@ -17,14 +17,11 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - - - /** * A class represents a collection of certificate record * specific schema information. * <P> - * + * * @author thomask * @version $Revision$, $Date$ */ 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 973ddc4f2..1981757cb 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/CertRecord.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/CertRecord.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.math.BigInteger; import java.security.cert.Certificate; import java.util.Date; @@ -34,12 +33,11 @@ import com.netscape.certsrv.dbs.IDBObj; import com.netscape.certsrv.dbs.certdb.ICertRecord; import com.netscape.certsrv.dbs.certdb.IRevocationInfo; - /** * A class represents a serializable certificate record. * <P> - * - * @author thomask + * + * @author thomask * @version $Revision$, $Date$ */ public class CertRecord implements IDBObj, ICertRecord { @@ -83,7 +81,7 @@ public class CertRecord implements IDBObj, ICertRecord { } /** - * Constructs certiificate record with certificate + * Constructs certiificate record with certificate * and meta info. */ public CertRecord(BigInteger id, Certificate cert, MetaInfo meta) { @@ -205,8 +203,8 @@ public class CertRecord implements IDBObj, ICertRecord { /** * Retrieves revocation information. */ - public IRevocationInfo getRevocationInfo() { - return mRevocationInfo; + public IRevocationInfo getRevocationInfo() { + return mRevocationInfo; } /** @@ -271,7 +269,7 @@ public class CertRecord implements IDBObj, ICertRecord { public Date getModifyTime() { return mModifyTime; } - + /** * String representation */ diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/CertRecordList.java b/pki/base/common/src/com/netscape/cmscore/dbs/CertRecordList.java index 3477360e0..29792880d 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/CertRecordList.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/CertRecordList.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Enumeration; import java.util.Vector; @@ -27,11 +26,10 @@ import com.netscape.certsrv.dbs.IElementProcessor; import com.netscape.certsrv.dbs.certdb.ICertRecord; import com.netscape.certsrv.dbs.certdb.ICertRecordList; - /** * A class represents a list of certificate records. * <P> - * + * * @author thomask mzhao * @version $Revision$, $Date$ */ @@ -71,17 +69,17 @@ public class CertRecordList implements ICertRecordList { /** * Process certificate record as soon as it is returned. * kmccarth: changed to ignore startidx and endidx because VLVs don't - * provide a stable list. + * provide a stable list. */ public void processCertRecords(int startidx, int endidx, - IElementProcessor ep) throws EBaseException { + IElementProcessor ep) throws EBaseException { int i = 0; - while ( i<mVlist.getSize() ) { - Object element = mVlist.getElementAt(i); - if (element != null && (! (element instanceof String)) ) { - ep.process(element); - } - i++; + while (i < mVlist.getSize()) { + Object element = mVlist.getElementAt(i); + if (element != null && (!(element instanceof String))) { + ep.process(element); + } + i++; } } @@ -91,7 +89,7 @@ public class CertRecordList implements ICertRecordList { * if the startidx, endidx are valid. */ public Enumeration<ICertRecord> getCertRecords(int startidx, int endidx) - throws EBaseException { + throws EBaseException { Vector<ICertRecord> entries = new Vector<ICertRecord>(); for (int i = startidx; i <= endidx; i++) { @@ -106,11 +104,10 @@ public class CertRecordList implements ICertRecordList { } public ICertRecord getCertRecord(int index) - throws EBaseException { + throws EBaseException { return mVlist.getElementAt(index); - } } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/CertRecordMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/CertRecordMapper.java index 510da3c54..3f5895ade 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/CertRecordMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/CertRecordMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.math.BigInteger; import java.util.Enumeration; import java.util.Vector; @@ -34,13 +33,12 @@ import com.netscape.certsrv.dbs.certdb.ICertRecord; import com.netscape.certsrv.dbs.certdb.ICertificateRepository; import com.netscape.cmscore.util.Debug; - /** - * A class represents a mapper to serialize + * A class represents a mapper to serialize * certificate record into database. * <P> - * - * @author thomask + * + * @author thomask * @version $Revision$, $Date$ */ public class CertRecordMapper implements IDBAttrMapper { @@ -58,9 +56,9 @@ public class CertRecordMapper implements IDBAttrMapper { return v.elements(); } - public void mapObjectToLDAPAttributeSet(IDBObj parent, String name, - Object obj, LDAPAttributeSet attrs) - throws EBaseException { + public void mapObjectToLDAPAttributeSet(IDBObj parent, String name, + Object obj, LDAPAttributeSet attrs) + throws EBaseException { try { CertRecord rec = (CertRecord) obj; @@ -74,9 +72,9 @@ public class CertRecordMapper implements IDBAttrMapper { } } - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { - try { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { + try { LDAPAttribute attr = attrs.getAttribute( CertDBSchema.LDAP_ATTR_CERT_RECORD_ID); @@ -95,7 +93,7 @@ public class CertRecordMapper implements IDBAttrMapper { } public String mapSearchFilter(String name, String op, String value) - throws EBaseException { + throws EBaseException { return name + op + value; } } 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 bc3d279f6..e27b710d5 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.io.Serializable; import java.math.BigInteger; import java.security.cert.Certificate; @@ -57,18 +56,17 @@ import com.netscape.certsrv.dbs.certdb.IRevocationInfo; import com.netscape.certsrv.dbs.repository.IRepository; import com.netscape.certsrv.logging.ILogger; - /** * A class represents a certificate repository. It * stores all the issued certificate. * <P> - * + * * @author thomask * @author kanda * @version $Revision$, $Date$ */ public class CertificateRepository extends Repository - implements ICertificateRepository { + implements ICertificateRepository { public final String CERT_X509ATTRIBUTE = "x509signedcert"; @@ -88,10 +86,10 @@ public class CertificateRepository extends Repository * Constructs a certificate repository. */ public CertificateRepository(IDBSubsystem dbService, String certRepoBaseDN, int increment, String baseDN) - throws EDBException { + throws EDBException { super(dbService, increment, baseDN); mBaseDN = certRepoBaseDN; - + mDBService = dbService; // registers CMS database attributes @@ -104,13 +102,12 @@ public class CertificateRepository extends Repository return new CertRecord(id, cert, meta); } - public BigInteger getLastSerialNumberInRange(BigInteger serial_low_bound, BigInteger serial_upper_bound) - throws EBaseException { + public BigInteger getLastSerialNumberInRange(BigInteger serial_low_bound, BigInteger serial_upper_bound) + throws EBaseException { CMS.debug("CertificateRepository: in getLastSerialNumberInRange: low " + serial_low_bound + " high " + serial_upper_bound); - if(serial_low_bound == null || serial_upper_bound == null || serial_low_bound.compareTo(serial_upper_bound) >= 0 ) - { + if (serial_low_bound == null || serial_upper_bound == null || serial_low_bound.compareTo(serial_upper_bound) >= 0) { return null; } @@ -119,7 +116,7 @@ public class CertificateRepository extends Repository String[] attrs = null; - ICertRecordList recList = findCertRecordsInList(ldapfilter,attrs,serial_upper_bound.toString(10),"serialno", 5 * -1); + ICertRecordList recList = findCertRecordsInList(ldapfilter, attrs, serial_upper_bound.toString(10), "serialno", 5 * -1); int size = recList.getSize(); @@ -130,13 +127,12 @@ public class CertificateRepository extends Repository BigInteger ret = new BigInteger(serial_low_bound.toString(10)); - ret = ret.add(new BigInteger("-1")); + ret = ret.add(new BigInteger("-1")); CMS.debug("CertificateRepository:getLastCertRecordSerialNo: returning " + ret); return ret; } int ltSize = recList.getSizeBeforeJumpTo(); - CMS.debug("CertificateRepository:getLastSerialNumberInRange: ltSize " + ltSize); CertRecord curRec = null; @@ -154,9 +150,8 @@ public class CertificateRepository extends Repository CMS.debug("CertificateRepository:getLastCertRecordSerialNo: serialno " + serial); - if( ((serial.compareTo(serial_low_bound) == 0) || (serial.compareTo(serial_low_bound) == 1) ) && - ((serial.compareTo(serial_upper_bound) == 0) || (serial.compareTo(serial_upper_bound) == -1) )) - { + if (((serial.compareTo(serial_low_bound) == 0) || (serial.compareTo(serial_low_bound) == 1)) && + ((serial.compareTo(serial_upper_bound) == 0) || (serial.compareTo(serial_upper_bound) == -1))) { CMS.debug("getLastSerialNumberInRange returning: " + serial); return serial; } @@ -164,24 +159,22 @@ public class CertificateRepository extends Repository CMS.debug("getLastSerialNumberInRange:found null from getCertRecord"); } } - BigInteger ret = new BigInteger(serial_low_bound.toString(10)); - ret = ret.add(new BigInteger("-1")); + ret = ret.add(new BigInteger("-1")); CMS.debug("CertificateRepository:getLastCertRecordSerialNo: returning " + ret); - return ret; + return ret; } /** * Removes all objects with this repository. */ - public void removeCertRecords(BigInteger beginS, BigInteger endS) throws EBaseException - { + public void removeCertRecords(BigInteger beginS, BigInteger endS) throws EBaseException { String filter = "(" + CertRecord.ATTR_CERT_STATUS + "=*" + ")"; - ICertRecordList list =findCertRecordsInList(filter, + ICertRecordList list = findCertRecordsInList(filter, null, "serialno", 10); int size = list.getSize(); Enumeration<ICertRecord> e = list.getCertRecords(0, size - 1); @@ -192,8 +185,8 @@ public class CertificateRepository extends Repository BigInteger min = cur; if (endS != null) min = cur.min(endS); - if (cur.equals(beginS) || cur.equals(endS) || - (cur.equals(max) && cur.equals(min))) + if (cur.equals(beginS) || cur.equals(endS) || + (cur.equals(max) && cur.equals(min))) deleteCertificateRecord(cur); } } @@ -224,8 +217,8 @@ public class CertificateRepository extends Repository /** * interval value: (in seconds) - * 0 - disable - * >0 - enable + * 0 - disable + * >0 - enable */ public CertStatusUpdateThread mCertStatusUpdateThread = null; public RetrieveModificationsThread mRetrieveModificationsThread = null; @@ -243,8 +236,8 @@ public class CertificateRepository extends Repository return; } - CMS.debug("In setCertStatusUpdateInterval listenToCloneModifications="+listenToCloneModifications+ - " mRetrieveModificationsThread="+mRetrieveModificationsThread); + CMS.debug("In setCertStatusUpdateInterval listenToCloneModifications=" + listenToCloneModifications + + " mRetrieveModificationsThread=" + mRetrieveModificationsThread); if (listenToCloneModifications && mRetrieveModificationsThread == null) { CMS.debug("In setCertStatusUpdateInterval about to create RetrieveModificationsThread"); mRetrieveModificationsThread = new RetrieveModificationsThread(this, "RetrieveModificationsThread"); @@ -273,7 +266,6 @@ public class CertificateRepository extends Repository } } - /** * Blocking method. */ @@ -281,21 +273,21 @@ public class CertificateRepository extends Repository CMS.debug("In updateCertStatus()"); - CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, - CMS.getLogMessage("CMSCORE_DBS_START_VALID_SEARCH")); + CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, + CMS.getLogMessage("CMSCORE_DBS_START_VALID_SEARCH")); transitInvalidCertificates(); CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, - CMS.getLogMessage("CMSCORE_DBS_FINISH_VALID_SEARCH")); + CMS.getLogMessage("CMSCORE_DBS_FINISH_VALID_SEARCH")); CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, - CMS.getLogMessage("CMSCORE_DBS_START_EXPIRED_SEARCH")); + CMS.getLogMessage("CMSCORE_DBS_START_EXPIRED_SEARCH")); transitValidCertificates(); CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, - CMS.getLogMessage("CMSCORE_DBS_FINISH_EXPIRED_SEARCH")); + CMS.getLogMessage("CMSCORE_DBS_FINISH_EXPIRED_SEARCH")); CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, - CMS.getLogMessage("CMSCORE_DBS_START_REVOKED_EXPIRED_SEARCH")); + CMS.getLogMessage("CMSCORE_DBS_START_REVOKED_EXPIRED_SEARCH")); transitRevokedExpiredCertificates(); CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, - CMS.getLogMessage("CMSCORE_DBS_FINISH_REVOKED_EXPIRED_SEARCH")); + CMS.getLogMessage("CMSCORE_DBS_FINISH_REVOKED_EXPIRED_SEARCH")); } /** @@ -305,13 +297,14 @@ public class CertificateRepository extends Repository return mBaseDN; } - public void setRequestDN( String requestDN ) { + public void setRequestDN(String requestDN) { mRequestBaseDN = requestDN; } - public String getRequestDN() { + public String getRequestDN() { return mRequestBaseDN; } + /** * Retrieves backend database handle. */ @@ -324,18 +317,18 @@ public class CertificateRepository extends Repository * record contains four parts: certificate, meta-attributes, * issue information and reovcation information. * <P> - * + * * @param cert X.509 certificate * @exception EBaseException failed to add new certificate to - * the repository + * the repository */ public void addCertificateRecord(ICertRecord record) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); try { String name = "cn" + "=" + - ((CertRecord) record).getSerialNumber().toString() + "," + getDN(); + ((CertRecord) record).getSerialNumber().toString() + "," + getDN(); SessionContext ctx = SessionContext.getContext(); String uid = (String) ctx.get(SessionContext.USER_ID); @@ -344,9 +337,9 @@ public class CertificateRepository extends Repository record.set(CertRecord.ATTR_ISSUED_BY, "system"); /** - System.out.println("XXX servlet should set USER_ID"); - throw new EBaseException(BaseResources.UNKNOWN_PRINCIPAL_1, - "null"); + * System.out.println("XXX servlet should set USER_ID"); + * throw new EBaseException(BaseResources.UNKNOWN_PRINCIPAL_1, + * "null"); **/ } else { record.set(CertRecord.ATTR_ISSUED_BY, uid); @@ -363,11 +356,11 @@ public class CertificateRepository extends Repository if (x509cert.getNotBefore().after(now)) { // not yet valid - record.set(ICertRecord.ATTR_CERT_STATUS, - ICertRecord.STATUS_INVALID); + record.set(ICertRecord.ATTR_CERT_STATUS, + ICertRecord.STATUS_INVALID); } } - + s.add(name, record); } finally { if (s != null) @@ -379,18 +372,18 @@ public class CertificateRepository extends Repository * Used by the Clone Master (CLA) to add a revoked certificate * record to the repository. * <p> - * + * * @param record a CertRecord * @exception EBaseException failed to add new certificate to - * the repository + * the repository */ public void addRevokedCertRecord(CertRecord record) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); try { String name = "cn" + "=" + - record.getSerialNumber().toString() + "," + getDN(); + record.getSerialNumber().toString() + "," + getDN(); s.add(name, record); } finally { @@ -431,7 +424,7 @@ public class CertificateRepository extends Repository for (i = 0; i < ltSize; i++) { obj = recList.getCertRecord(i); - if (obj != null) { + if (obj != null) { curRec = (CertRecord) obj; Date notAfter = curRec.getNotAfter(); @@ -467,7 +460,7 @@ public class CertificateRepository extends Repository public void transitRevokedExpiredCertificates() throws EBaseException { Date now = CMS.getCurrentDate(); ICertRecordList recList = getRevokedCertsByNotAfterDate(now, -1 * mTransitRecordPageSize); - + int size = recList.getSize(); if (size <= 0) { @@ -506,7 +499,7 @@ public class CertificateRepository extends Repository } else { cList.add(curRec.getSerialNumber()); } - } else { + } else { CMS.debug("found null record in getCertRecord"); } } @@ -600,7 +593,7 @@ public class CertificateRepository extends Repository updateStatus(serial, newCertStatus); if (newCertStatus.equals(CertRecord.STATUS_REVOKED_EXPIRED)) { - + // inform all CRLIssuingPoints about revoked and expired certificate Enumeration<ICRLIssuingPoint> eIPs = mCRLIssuingPoints.elements(); @@ -625,7 +618,7 @@ public class CertificateRepository extends Repository * Reads the certificate identified by the given serial no. */ public X509CertImpl getX509Certificate(BigInteger serialNo) - throws EBaseException { + throws EBaseException { X509CertImpl cert = null; ICertRecord cr = readCertificateRecord(serialNo); @@ -636,16 +629,16 @@ public class CertificateRepository extends Repository * Deletes certificate record. */ public void deleteCertificateRecord(BigInteger serialNo) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); try { String name = "cn" + "=" + - serialNo.toString() + "," + getDN(); + serialNo.toString() + "," + getDN(); s.delete(name); } finally { - if (s != null) + if (s != null) s.close(); } } @@ -654,35 +647,35 @@ public class CertificateRepository extends Repository * Reads certificate from repository. */ public ICertRecord readCertificateRecord(BigInteger serialNo) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); CertRecord rec = null; try { String name = "cn" + "=" + - serialNo.toString() + "," + getDN(); + serialNo.toString() + "," + getDN(); rec = (CertRecord) s.read(name); } finally { - if (s != null) + if (s != null) s.close(); } return rec; } public synchronized void modifyCertificateRecord(BigInteger serialNo, - ModificationSet mods) throws EBaseException { + ModificationSet mods) throws EBaseException { IDBSSession s = mDBService.createSession(); try { String name = "cn" + "=" + - serialNo.toString() + "," + getDN(); + serialNo.toString() + "," + getDN(); mods.add(CertRecord.ATTR_MODIFY_TIME, Modification.MOD_REPLACE, - CMS.getCurrentDate()); + CMS.getCurrentDate()); s.modify(name, mods); } finally { - if (s != null) + if (s != null) s.close(); } } @@ -691,7 +684,7 @@ public class CertificateRepository extends Repository * Checks if the specified certificate is in the repository. */ public boolean containsCertificate(BigInteger serialNo) - throws EBaseException { + throws EBaseException { try { ICertRecord cr = readCertificateRecord(serialNo); @@ -706,7 +699,7 @@ public class CertificateRepository extends Repository * Marks certificate as revoked. */ public void markAsRevoked(BigInteger id, IRevocationInfo info) - throws EBaseException { + throws EBaseException { ModificationSet mods = new ModificationSet(); mods.add(CertRecord.ATTR_REVO_INFO, Modification.MOD_ADD, info); @@ -715,15 +708,15 @@ public class CertificateRepository extends Repository if (uid == null) { mods.add(CertRecord.ATTR_REVOKED_BY, Modification.MOD_ADD, - "system"); + "system"); } else { mods.add(CertRecord.ATTR_REVOKED_BY, Modification.MOD_ADD, - uid); + uid); } mods.add(CertRecord.ATTR_REVOKED_ON, Modification.MOD_ADD, - CMS.getCurrentDate()); + CMS.getCurrentDate()); mods.add(CertRecord.ATTR_CERT_STATUS, Modification.MOD_REPLACE, - CertRecord.STATUS_REVOKED); + CertRecord.STATUS_REVOKED); modifyCertificateRecord(id, mods); } @@ -731,15 +724,15 @@ public class CertificateRepository extends Repository * Unmarks revoked certificate. */ public void unmarkRevoked(BigInteger id, IRevocationInfo info, - Date revokedOn, String revokedBy) - throws EBaseException { + Date revokedOn, String revokedBy) + throws EBaseException { ModificationSet mods = new ModificationSet(); mods.add(CertRecord.ATTR_REVO_INFO, Modification.MOD_DELETE, info); mods.add(CertRecord.ATTR_REVOKED_BY, Modification.MOD_DELETE, revokedBy); mods.add(CertRecord.ATTR_REVOKED_ON, Modification.MOD_DELETE, revokedOn); mods.add(CertRecord.ATTR_CERT_STATUS, Modification.MOD_REPLACE, - CertRecord.STATUS_VALID); + CertRecord.STATUS_VALID); modifyCertificateRecord(id, mods); } @@ -747,17 +740,17 @@ public class CertificateRepository extends Repository * Updates the certificiate record status to the specified. */ public void updateStatus(BigInteger id, String status) - throws EBaseException { + throws EBaseException { CMS.debug("updateStatus: " + id + " status " + status); ModificationSet mods = new ModificationSet(); mods.add(CertRecord.ATTR_CERT_STATUS, Modification.MOD_REPLACE, - status); + status); modifyCertificateRecord(id, mods); } public Enumeration searchCertificates(String filter, int maxSize) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; @@ -765,14 +758,14 @@ public class CertificateRepository extends Repository try { e = s.search(getDN(), filter, maxSize); } finally { - if (s != null) + if (s != null) s.close(); } return e; } public Enumeration searchCertificates(String filter, int maxSize, int timeLimit) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; @@ -780,7 +773,7 @@ public class CertificateRepository extends Repository try { e = s.search(getDN(), filter, maxSize, timeLimit); } finally { - if (s != null) + if (s != null) s.close(); } return e; @@ -788,39 +781,42 @@ public class CertificateRepository extends Repository /** * Returns a list of X509CertImp that satisfies the filter. + * * @deprecated replaced by <code>findCertificatesInList</code> */ public Enumeration findCertRecs(String filter) - throws EBaseException { + throws EBaseException { CMS.debug("findCertRecs " + filter); IDBSSession s = mDBService.createSession(); Enumeration e = null; try { e = s.search(getDN(), filter); } finally { - if (s != null) s.close(); + if (s != null) + s.close(); } return e; } public Enumeration findCertRecs(String filter, String[] attrs) - throws EBaseException { + throws EBaseException { - CMS.debug( "findCertRecs " + filter - + "attrs " + Arrays.toString( attrs ) ); + CMS.debug("findCertRecs " + filter + + "attrs " + Arrays.toString(attrs)); IDBSSession s = mDBService.createSession(); Enumeration e = null; try { e = s.search(getDN(), filter, attrs); } finally { - if (s != null) s.close(); + if (s != null) + s.close(); } return e; } public Enumeration<X509CertImpl> findCertificates(String filter) - throws EBaseException { + throws EBaseException { Enumeration e = findCertRecords(filter); Vector<X509CertImpl> v = new Vector<X509CertImpl>(); @@ -839,7 +835,7 @@ public class CertificateRepository extends Repository * use this. */ public Enumeration findCertRecords(String filter) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; @@ -852,7 +848,7 @@ public class CertificateRepository extends Repository e = list.getCertRecords(0, size - 1); } finally { - if (s != null) + if (s != null) s.close(); } return e; @@ -861,6 +857,7 @@ public class CertificateRepository extends Repository /** * Finds certificate records. Here is a list of filter * attribute can be used: + * * <pre> * certRecordId * certMetaInfo @@ -871,49 +868,51 @@ public class CertificateRepository extends Repository * x509Cert.notAfter * x509Cert.subject * </pre> + * * The filter should follow RFC1558 LDAP filter syntax. * For example, + * * <pre> * (&(certRecordId=5)(x509Cert.notBefore=934398398)) * </pre> */ - public ICertRecordList findCertRecordsInList(String filter, - String attrs[], int pageSize) throws EBaseException { - return findCertRecordsInList(filter, attrs, CertRecord.ATTR_ID, + public ICertRecordList findCertRecordsInList(String filter, + String attrs[], int pageSize) throws EBaseException { + return findCertRecordsInList(filter, attrs, CertRecord.ATTR_ID, pageSize); } - public ICertRecordList findCertRecordsInList(String filter, - String attrs[], String sortKey, int pageSize) - throws EBaseException { + public ICertRecordList findCertRecordsInList(String filter, + String attrs[], String sortKey, int pageSize) + throws EBaseException { IDBSSession s = mDBService.createSession(); CMS.debug("In findCertRecordsInList"); CertRecordList list = null; try { - IDBVirtualList<ICertRecord> vlist = s.createVirtualList(getDN(), filter, attrs, + IDBVirtualList<ICertRecord> vlist = s.createVirtualList(getDN(), filter, attrs, sortKey, pageSize); list = new CertRecordList(vlist); } finally { - if (s != null) + if (s != null) s.close(); } return list; } - public ICertRecordList findCertRecordsInList(String filter, - String attrs[], String jumpTo, String sortKey, int pageSize) - throws EBaseException { - return findCertRecordsInList(filter, attrs, jumpTo, false, sortKey, pageSize); + public ICertRecordList findCertRecordsInList(String filter, + String attrs[], String jumpTo, String sortKey, int pageSize) + throws EBaseException { + return findCertRecordsInList(filter, attrs, jumpTo, false, sortKey, pageSize); } - public ICertRecordList findCertRecordsInList(String filter, - String attrs[], String jumpTo, boolean hardJumpTo, - String sortKey, int pageSize) - throws EBaseException { + public ICertRecordList findCertRecordsInList(String filter, + String attrs[], String jumpTo, boolean hardJumpTo, + String sortKey, int pageSize) + throws EBaseException { IDBSSession s = mDBService.createSession(); CertRecordList list = null; @@ -921,33 +920,33 @@ public class CertificateRepository extends Repository try { String jumpToVal = null; - if (hardJumpTo) { - CMS.debug("In findCertRecordsInList with hardJumpto "); - jumpToVal = "99"; - } else { - int len = jumpTo.length(); - - if (len > 9) { - jumpToVal = Integer.toString(len) + jumpTo; + if (hardJumpTo) { + CMS.debug("In findCertRecordsInList with hardJumpto "); + jumpToVal = "99"; } else { - jumpToVal = "0" + Integer.toString(len) + jumpTo; + int len = jumpTo.length(); + + if (len > 9) { + jumpToVal = Integer.toString(len) + jumpTo; + } else { + jumpToVal = "0" + Integer.toString(len) + jumpTo; + } } - } - IDBVirtualList<ICertRecord> vlist = s.createVirtualList(getDN(), filter, + IDBVirtualList<ICertRecord> vlist = s.createVirtualList(getDN(), filter, attrs, jumpToVal, sortKey, pageSize); list = new CertRecordList(vlist); } finally { - if (s != null) + if (s != null) s.close(); } return list; } public ICertRecordList findCertRecordsInListRawJumpto(String filter, - String attrs[], String jumpTo, String sortKey, int pageSize) - throws EBaseException { + String attrs[], String jumpTo, String sortKey, int pageSize) + throws EBaseException { IDBSSession s = mDBService.createSession(); CertRecordList list = null; @@ -955,7 +954,7 @@ public class CertificateRepository extends Repository try { - IDBVirtualList<ICertRecord> vlist = s.createVirtualList(getDN(), filter, + IDBVirtualList<ICertRecord> vlist = s.createVirtualList(getDN(), filter, attrs, jumpTo, sortKey, pageSize); list = new CertRecordList(vlist); @@ -970,44 +969,44 @@ public class CertificateRepository extends Repository * Marks certificate as renewable. */ public void markCertificateAsRenewable(ICertRecord record) - throws EBaseException { + throws EBaseException { changeRenewalAttribute(((CertRecord) record).getSerialNumber().toString(), - CertRecord.AUTO_RENEWAL_ENABLED); + CertRecord.AUTO_RENEWAL_ENABLED); } /** * Marks certificate as renewable. */ public void markCertificateAsNotRenewable(ICertRecord record) - throws EBaseException { + throws EBaseException { changeRenewalAttribute(((CertRecord) record).getSerialNumber().toString(), - CertRecord.AUTO_RENEWAL_DISABLED); + CertRecord.AUTO_RENEWAL_DISABLED); } public void markCertificateAsRenewed(String serialNo) - throws EBaseException { + throws EBaseException { changeRenewalAttribute(serialNo, CertRecord.AUTO_RENEWAL_DONE); } public void markCertificateAsRenewalNotified(String serialNo) - throws EBaseException { + throws EBaseException { changeRenewalAttribute(serialNo, CertRecord.AUTO_RENEWAL_NOTIFIED); } private void changeRenewalAttribute(String serialno, String value) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); try { String name = "cn" + "=" + serialno + - "," + getDN(); + "," + getDN(); ModificationSet mods = new ModificationSet(); mods.add(CertRecord.ATTR_AUTO_RENEW, Modification.MOD_REPLACE, - value); + value); s.modify(name, mods); } finally { - if (s != null) + if (s != null) s.close(); } } @@ -1018,6 +1017,7 @@ public class CertificateRepository extends Repository public class RenewableCertificateCollection { Vector<Object> mToRenew = null; Vector<Object> mToNotify = null; + public RenewableCertificateCollection() { } @@ -1044,20 +1044,20 @@ public class CertificateRepository extends Repository } public Hashtable<String, RenewableCertificateCollection> getRenewableCertificates(String renewalTime) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Hashtable<String, RenewableCertificateCollection> tab = null; try { String filter = "(&(" + CertRecord.ATTR_CERT_STATUS + "=" + - CertRecord.STATUS_VALID + ")(" - + CertRecord.ATTR_X509CERT + - "." + CertificateValidity.NOT_AFTER + "<=" + renewalTime + - ")(!(" + CertRecord.ATTR_AUTO_RENEW + "=" + - CertRecord.AUTO_RENEWAL_DONE + - "))(!(" + CertRecord.ATTR_AUTO_RENEW + "=" + - CertRecord.AUTO_RENEWAL_NOTIFIED + ")))"; + CertRecord.STATUS_VALID + ")(" + + CertRecord.ATTR_X509CERT + + "." + CertificateValidity.NOT_AFTER + "<=" + renewalTime + + ")(!(" + CertRecord.ATTR_AUTO_RENEW + "=" + + CertRecord.AUTO_RENEWAL_DONE + + "))(!(" + CertRecord.ATTR_AUTO_RENEW + "=" + + CertRecord.AUTO_RENEWAL_NOTIFIED + ")))"; //Enumeration e = s.search(getDN(), filter); ICertRecordList list = null; @@ -1077,7 +1077,7 @@ public class CertificateRepository extends Repository if ((val = tab.get(subjectDN)) == null) { RenewableCertificateCollection collection = - new RenewableCertificateCollection(); + new RenewableCertificateCollection(); collection.addCertificate(renewalFlag, cert); tab.put(subjectDN, collection); @@ -1086,7 +1086,7 @@ public class CertificateRepository extends Repository } } } finally { - if (s != null) + if (s != null) s.close(); } return tab; @@ -1095,14 +1095,14 @@ public class CertificateRepository extends Repository /** * Gets all valid and unexpired certificates pertaining * to a subject DN. - * - * @param subjectDN The distinguished name of the subject. - * @param validityType The type of certificates to get. + * + * @param subjectDN The distinguished name of the subject. + * @param validityType The type of certificates to get. * @return An array of certificates. */ public X509CertImpl[] getX509Certificates(String subjectDN, - int validityType) throws EBaseException { + int validityType) throws EBaseException { IDBSSession s = mDBService.createSession(); X509CertImpl certs[] = null; @@ -1110,7 +1110,7 @@ public class CertificateRepository extends Repository try { // XXX - not checking validityType... String filter = "(&(" + CertRecord.ATTR_X509CERT + - "." + X509CertInfo.SUBJECT + "=" + subjectDN; + "." + X509CertInfo.SUBJECT + "=" + subjectDN; if (validityType == ALL_VALID_CERTS) { filter += ")(" + @@ -1145,14 +1145,14 @@ public class CertificateRepository extends Repository certs = new X509CertImpl[v.size()]; v.copyInto(certs); } finally { - if (s != null) + if (s != null) s.close(); } return certs; } public X509CertImpl[] getX509Certificates(String filter) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); X509CertImpl certs[] = null; @@ -1182,7 +1182,7 @@ public class CertificateRepository extends Repository v.copyInto(certs); } } finally { - if (s != null) + if (s != null) s.close(); } return certs; @@ -1190,82 +1190,83 @@ public class CertificateRepository extends Repository /** * Retrives all valid certificates excluding ones already revoked. - * @param from The starting point of the serial number range. - * @param to The ending point of the serial number range. + * + * @param from The starting point of the serial number range. + * @param to The ending point of the serial number range. */ public Enumeration<CertRecord> getValidCertificates(String from, String to) - throws EBaseException { - IDBSSession s = mDBService.createSession(); - Vector<CertRecord> v = new Vector<CertRecord>(); + throws EBaseException { + IDBSSession s = mDBService.createSession(); + Vector<CertRecord> v = new Vector<CertRecord>(); - try { + try { - // 'from' determines 'jumpto' value - // 'to' determines where to stop looking + // 'from' determines 'jumpto' value + // 'to' determines where to stop looking - String ldapfilter = "(certstatus=VALID)"; + String ldapfilter = "(certstatus=VALID)"; - String fromVal = "0"; - try { - if (from != null) { - int fv = Integer.parseInt(from); - fromVal = from; - } - } catch (Exception e1) { - // from is not integer + String fromVal = "0"; + try { + if (from != null) { + int fv = Integer.parseInt(from); + fromVal = from; } + } catch (Exception e1) { + // from is not integer + } - ICertRecordList list = - findCertRecordsInList(ldapfilter, null, fromVal, "serialno", 40); + ICertRecordList list = + findCertRecordsInList(ldapfilter, null, fromVal, "serialno", 40); - BigInteger toInt = null; - if (to != null && !to.trim().equals("")) { - toInt = new BigInteger(to); - } + BigInteger toInt = null; + if (to != null && !to.trim().equals("")) { + toInt = new BigInteger(to); + } - for (int i=0;; i++) { - CertRecord rec = (CertRecord) list.getCertRecord(i); - CMS.debug("processing record: "+i); - if (rec == null) { - break; // no element returned - } else { - - CMS.debug("processing record: "+i+" "+rec.getSerialNumber()); - // Check if we are past the 'to' marker - if (toInt != null) { - if (rec.getSerialNumber().compareTo(toInt) > 0) { - break; - } + for (int i = 0;; i++) { + CertRecord rec = (CertRecord) list.getCertRecord(i); + CMS.debug("processing record: " + i); + if (rec == null) { + break; // no element returned + } else { + + CMS.debug("processing record: " + i + " " + rec.getSerialNumber()); + // Check if we are past the 'to' marker + if (toInt != null) { + if (rec.getSerialNumber().compareTo(toInt) > 0) { + break; } - v.addElement(rec); - } - } - - } finally { - if (s != null) - s.close(); - } - CMS.debug("returning "+v.size()+" elements"); - return v.elements(); - } + } + v.addElement(rec); + } + } + + } finally { + if (s != null) + s.close(); + } + CMS.debug("returning " + v.size() + " elements"); + return v.elements(); + } /** * Retrives all valid certificates excluding ones already revoked. */ public Enumeration getAllValidCertificates() - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; try { Date now = CMS.getCurrentDate(); String ldapfilter = "(&(!(" + CertRecord.ATTR_REVO_INFO + "=*))(" + - CertRecord.ATTR_X509CERT + "." + - CertificateValidity.NOT_BEFORE + "<=" + - DateMapper.dateToDB(now) + ")(" + - CertRecord.ATTR_X509CERT + "." + - CertificateValidity.NOT_AFTER + ">=" + - DateMapper.dateToDB(now) + "))"; + CertRecord.ATTR_X509CERT + "." + + CertificateValidity.NOT_BEFORE + "<=" + + DateMapper.dateToDB(now) + ")(" + + CertRecord.ATTR_X509CERT + "." + + CertificateValidity.NOT_AFTER + ">=" + + DateMapper.dateToDB(now) + "))"; //e = s.search(getDN(), ldapfilter); ICertRecordList list = null; @@ -1273,23 +1274,24 @@ public class CertificateRepository extends Repository int size = list.getSize(); e = list.getCertRecords(0, size - 1); - + } finally { // XXX - transaction is not done at this moment - if (s != null) + if (s != null) s.close(); } return e; } /** - * Retrives all valid not published certificates + * Retrives all valid not published certificates * excluding ones already revoked. - * @param from The starting point of the serial number range. - * @param to The ending point of the serial number range. + * + * @param from The starting point of the serial number range. + * @param to The ending point of the serial number range. */ public Enumeration getValidNotPublishedCertificates(String from, String to) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; @@ -1318,35 +1320,35 @@ public class CertificateRepository extends Repository int size = list.getSize(); e = list.getCertRecords(0, size - 1); - + } finally { - if (s != null) + if (s != null) s.close(); } return e; } /** - * Retrives all valid not published certificates + * Retrives all valid not published certificates * excluding ones already revoked. */ public Enumeration getAllValidNotPublishedCertificates() - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; try { Date now = CMS.getCurrentDate(); String ldapfilter = "(&(!(" + CertRecord.ATTR_REVO_INFO + "=*))(" + - CertRecord.ATTR_X509CERT + "." + - CertificateValidity.NOT_BEFORE + "<=" + - DateMapper.dateToDB(now) + ")(" + - CertRecord.ATTR_X509CERT + "." + - CertificateValidity.NOT_AFTER + ">=" + - DateMapper.dateToDB(now) + ")(!(" + - "certMetainfo=" + - CertRecord.META_LDAPPUBLISH + - ":true)))"; + CertRecord.ATTR_X509CERT + "." + + CertificateValidity.NOT_BEFORE + "<=" + + DateMapper.dateToDB(now) + ")(" + + CertRecord.ATTR_X509CERT + "." + + CertificateValidity.NOT_AFTER + ">=" + + DateMapper.dateToDB(now) + ")(!(" + + "certMetainfo=" + + CertRecord.META_LDAPPUBLISH + + ":true)))"; //e = s.search(getDN(), ldapfilter); ICertRecordList list = null; @@ -1354,10 +1356,10 @@ public class CertificateRepository extends Repository int size = list.getSize(); e = list.getCertRecords(0, size - 1); - + } finally { // XXX - transaction is not done at this moment - if (s != null) + if (s != null) s.close(); } return e; @@ -1365,11 +1367,12 @@ public class CertificateRepository extends Repository /** * Retrives all expired certificates. - * @param from The starting point of the serial number range. - * @param to The ending point of the serial number range. + * + * @param from The starting point of the serial number range. + * @param to The ending point of the serial number range. */ public Enumeration getExpiredCertificates(String from, String to) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; @@ -1385,16 +1388,16 @@ public class CertificateRepository extends Repository CertificateValidity.NOT_AFTER + ">=" + DateMapper.dateToDB(now) + ")))"; //e = s.search(getDN(), ldapfilter); - + ICertRecordList list = null; list = findCertRecordsInList(ldapfilter, null, "serialno", 10); int size = list.getSize(); e = list.getCertRecords(0, size - 1); - } finally { + } finally { // XXX - transaction is not done at this moment - if (s != null) + if (s != null) s.close(); } return e; @@ -1404,15 +1407,15 @@ public class CertificateRepository extends Repository * Retrives all expired certificates. */ public Enumeration getAllExpiredCertificates() - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; try { Date now = CMS.getCurrentDate(); String ldapfilter = "(!(" + CertRecord.ATTR_X509CERT + "." + - CertificateValidity.NOT_AFTER + ">=" + - DateMapper.dateToDB(now) + "))"; + CertificateValidity.NOT_AFTER + ">=" + + DateMapper.dateToDB(now) + "))"; //e = s.search(getDN(), ldapfilter); ICertRecordList list = null; @@ -1420,10 +1423,10 @@ public class CertificateRepository extends Repository int size = list.getSize(); e = list.getCertRecords(0, size - 1); - - } finally { + + } finally { // XXX - transaction is not done at this moment - if (s != null) + if (s != null) s.close(); } return e; @@ -1431,11 +1434,12 @@ public class CertificateRepository extends Repository /** * Retrives all expired published certificates. - * @param from The starting point of the serial number range. - * @param to The ending point of the serial number range. + * + * @param from The starting point of the serial number range. + * @param to The ending point of the serial number range. */ public Enumeration getExpiredPublishedCertificates(String from, String to) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; @@ -1455,16 +1459,16 @@ public class CertificateRepository extends Repository CertRecord.META_LDAPPUBLISH + ":true))"; //e = s.search(getDN(), ldapfilter); - + ICertRecordList list = null; list = findCertRecordsInList(ldapfilter, null, "serialno", 10); int size = list.getSize(); e = list.getCertRecords(0, size - 1); - } finally { + } finally { // XXX - transaction is not done at this moment - if (s != null) + if (s != null) s.close(); } return e; @@ -1474,7 +1478,7 @@ public class CertificateRepository extends Repository * Retrives all expired publishedcertificates. */ public Enumeration getAllExpiredPublishedCertificates() - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; @@ -1488,7 +1492,7 @@ public class CertificateRepository extends Repository ldapfilter += "(certMetainfo=" + CertRecord.META_LDAPPUBLISH + ":true))"; - + //e = s.search(getDN(), ldapfilter); ICertRecordList list = null; @@ -1496,17 +1500,17 @@ public class CertificateRepository extends Repository int size = list.getSize(); e = list.getCertRecords(0, size - 1); - - } finally { + + } finally { // XXX - transaction is not done at this moment - if (s != null) + if (s != null) s.close(); } return e; } public ICertRecordList getInvalidCertsByNotBeforeDate(Date date, int pageSize) - throws EBaseException { + throws EBaseException { String now = null; @@ -1521,7 +1525,7 @@ public class CertificateRepository extends Repository String[] attrs = null; if (mConsistencyCheck == false) { - attrs = new String[] { "objectclass", CertRecord.ATTR_ID, CertRecord.ATTR_X509CERT}; + attrs = new String[] { "objectclass", CertRecord.ATTR_ID, CertRecord.ATTR_X509CERT }; } CMS.debug("getInvalidCertificatesByNotBeforeDate filter " + ldapfilter); @@ -1536,7 +1540,6 @@ public class CertificateRepository extends Repository } finally { // XXX - transaction is not done at this moment - CMS.debug("In getInvalidCertsByNotBeforeDate finally."); if (s != null) @@ -1547,7 +1550,7 @@ public class CertificateRepository extends Repository } public ICertRecordList getValidCertsByNotAfterDate(Date date, int pageSize) - throws EBaseException { + throws EBaseException { String now = null; @@ -1560,7 +1563,7 @@ public class CertificateRepository extends Repository String[] attrs = null; if (mConsistencyCheck == false) { - attrs = new String[] { "objectclass", CertRecord.ATTR_ID, CertRecord.ATTR_X509CERT}; + attrs = new String[] { "objectclass", CertRecord.ATTR_ID, CertRecord.ATTR_X509CERT }; } CMS.debug("getValidCertsByNotAfterDate filter " + ldapfilter); @@ -1577,7 +1580,7 @@ public class CertificateRepository extends Repository } public ICertRecordList getRevokedCertsByNotAfterDate(Date date, int pageSize) - throws EBaseException { + throws EBaseException { ICertRecordList list = null; IDBSSession s = mDBService.createSession(); @@ -1589,7 +1592,7 @@ public class CertificateRepository extends Repository if (mConsistencyCheck == false) { attrs = new String[] { "objectclass", CertRecord.ATTR_REVOKED_ON, CertRecord.ATTR_ID, - CertRecord.ATTR_REVO_INFO, CertificateValidity.NOT_AFTER, CertRecord.ATTR_X509CERT}; + CertRecord.ATTR_REVO_INFO, CertificateValidity.NOT_AFTER, CertRecord.ATTR_X509CERT }; } CMS.debug("getRevokedCertificatesByNotAfterDate filter " + ldapfilter); @@ -1602,21 +1605,21 @@ public class CertificateRepository extends Repository } finally { // XXX - transaction is not done at this moment - if (s != null) s.close(); } return list; } - + /** - * Retrieves all revoked certificates in the serial number range. - * @param from The starting point of the serial number range. - * @param to The ending point of the serial number range. + * Retrieves all revoked certificates in the serial number range. + * + * @param from The starting point of the serial number range. + * @param to The ending point of the serial number range. */ public Enumeration getRevokedCertificates(String from, String to) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; @@ -1637,18 +1640,18 @@ public class CertificateRepository extends Repository e = list.getCertRecords(0, size - 1); } finally { // XXX - transaction is not done at this moment - if (s != null) + if (s != null) s.close(); } return e; } /** - * Retrives all revoked certificates including ones already expired or + * Retrives all revoked certificates including ones already expired or * not yet valid. */ public Enumeration getAllRevokedCertificates() - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; String ldapfilter = "(|(" + CertRecord.ATTR_CERT_STATUS + "=" + CertRecord.STATUS_REVOKED + ")(" + CertRecord.ATTR_CERT_STATUS + "=" + CertRecord.STATUS_REVOKED_EXPIRED + "))"; // index is setup for this filter @@ -1662,19 +1665,20 @@ public class CertificateRepository extends Repository e = list.getCertRecords(0, size - 1); } finally { - if (s != null) + if (s != null) s.close(); } return e; } /** - * Retrieves all revoked publishedcertificates in the serial number range. - * @param from The starting point of the serial number range. - * @param to The ending point of the serial number range. + * Retrieves all revoked publishedcertificates in the serial number range. + * + * @param from The starting point of the serial number range. + * @param to The ending point of the serial number range. */ public Enumeration getRevokedPublishedCertificates(String from, String to) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; @@ -1685,7 +1689,7 @@ public class CertificateRepository extends Repository ldapfilter += "(" + CertRecord.ATTR_ID + ">=" + from + ")"; if (to != null && to.length() > 0) ldapfilter += "(" + CertRecord.ATTR_ID + "<=" + to + ")"; - //ldapfilter += ")"; + //ldapfilter += ")"; ldapfilter += "(certMetainfo=" + CertRecord.META_LDAPPUBLISH + ":true))"; @@ -1698,18 +1702,18 @@ public class CertificateRepository extends Repository e = list.getCertRecords(0, size - 1); } finally { // XXX - transaction is not done at this moment - if (s != null) + if (s != null) s.close(); } return e; } /** - * Retrives all revoked published certificates including ones + * Retrives all revoked published certificates including ones * already expired or not yet valid. */ public Enumeration getAllRevokedPublishedCertificates() - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; String ldapfilter = "(&(|(" + CertRecord.ATTR_CERT_STATUS + "=" + CertRecord.STATUS_REVOKED + ")(" + CertRecord.ATTR_CERT_STATUS + "=" + CertRecord.STATUS_REVOKED_EXPIRED + "))"; // index is setup for this filter @@ -1726,17 +1730,17 @@ public class CertificateRepository extends Repository e = list.getCertRecords(0, size - 1); } finally { - if (s != null) + if (s != null) s.close(); } return e; } /** - * Retrieves all revoked certificates that have not expired. + * Retrieves all revoked certificates that have not expired. */ public Enumeration getRevokedCertificates(Date asOfDate) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; @@ -1747,9 +1751,9 @@ public class CertificateRepository extends Repository "." + CertificateValidity.NOT_AFTER + " >= " + DateMapper.dateToDB(asOfDate) + "))");*/ String ldapfilter = "(&(" + - CertRecord.ATTR_REVO_INFO + "=*)(" + CertRecord.ATTR_X509CERT + - "." + CertificateValidity.NOT_AFTER + " >= " + - DateMapper.dateToDB(asOfDate) + "))"; + CertRecord.ATTR_REVO_INFO + "=*)(" + CertRecord.ATTR_X509CERT + + "." + CertificateValidity.NOT_AFTER + " >= " + + DateMapper.dateToDB(asOfDate) + "))"; ICertRecordList list = null; list = findCertRecordsInList(ldapfilter, null, "serialno", 10); @@ -1758,7 +1762,7 @@ public class CertificateRepository extends Repository e = list.getCertRecords(0, size - 1); } finally { // XXX - transaction is not done at this moment - if (s != null) + if (s != null) s.close(); } return e; @@ -1768,7 +1772,7 @@ public class CertificateRepository extends Repository * Retrives all revoked certificates excluing ones already expired. */ public Enumeration getAllRevokedNonExpiredCertificates() - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration e = null; String ldapfilter = "(" + CertRecord.ATTR_CERT_STATUS + "=" + CertRecord.STATUS_REVOKED + ")"; // index is setup for this filter @@ -1782,14 +1786,14 @@ public class CertificateRepository extends Repository e = list.getCertRecords(0, size - 1); } finally { - if (s != null) + if (s != null) s.close(); } return e; } private LDAPSearchResults startSearchForModifiedCertificateRecords() - throws EBaseException { + throws EBaseException { CMS.debug("startSearchForModifiedCertificateRecords"); LDAPSearchResults r = null; IDBSSession s = mDBService.createSession(); @@ -1799,9 +1803,9 @@ public class CertificateRepository extends Repository r = s.persistentSearch(getDN(), filter, null); CMS.debug("startSearchForModifiedCertificateRecords persistentSearch started"); } catch (Exception e) { - CMS.debug("startSearchForModifiedCertificateRecords persistentSearch Exception="+e); + CMS.debug("startSearchForModifiedCertificateRecords persistentSearch Exception=" + e); r = null; - if (s != null) + if (s != null) s.close(); } return r; @@ -1809,20 +1813,20 @@ public class CertificateRepository extends Repository public void getModifications(LDAPEntry entry) { if (entry != null) { - CMS.debug("getModifications entry DN="+entry.getDN()); + CMS.debug("getModifications entry DN=" + entry.getDN()); LDAPAttributeSet entryAttrs = entry.getAttributeSet(); ICertRecord certRec = null; try { - certRec = (ICertRecord)mDBService.getRegistry().createObject(entryAttrs); + certRec = (ICertRecord) mDBService.getRegistry().createObject(entryAttrs); } catch (Exception e) { } if (certRec != null) { String status = certRec.getStatus(); - CMS.debug("getModifications serialNumber="+certRec.getSerialNumber()+ - " status="+status); + CMS.debug("getModifications serialNumber=" + certRec.getSerialNumber() + + " status=" + status); if (status != null && (status.equals(ICertRecord.STATUS_VALID) || - status.equals(ICertRecord.STATUS_REVOKED))) { + status.equals(ICertRecord.STATUS_REVOKED))) { Enumeration<ICRLIssuingPoint> eIPs = mCRLIssuingPoints.elements(); @@ -1834,7 +1838,7 @@ public class CertificateRepository extends Repository IRevocationInfo rInfo = certRec.getRevocationInfo(); if (rInfo != null) { ip.addRevokedCert(certRec.getSerialNumber(), - new RevokedCertImpl(certRec.getSerialNumber(), + new RevokedCertImpl(certRec.getSerialNumber(), rInfo.getRevocationDate(), rInfo.getCRLEntryExtensions())); } @@ -1851,16 +1855,15 @@ public class CertificateRepository extends Repository } } - /** * Checks if the presented certificate belongs to the repository * and is revoked. - * - * @param cert certificate to verify. + * + * @param cert certificate to verify. * @return RevocationInfo if the presented certificate is revoked otherwise null. */ public RevocationInfo isCertificateRevoked(X509CertImpl cert) - throws EBaseException { + throws EBaseException { RevocationInfo info = null; // 615932 @@ -1885,8 +1888,8 @@ public class CertificateRepository extends Repository } if (certEncoded != null && - repCertEncoded != null && - certEncoded.length == repCertEncoded.length) { + repCertEncoded != null && + certEncoded.length == repCertEncoded.length) { int i; for (i = 0; i < certEncoded.length; i++) { @@ -1913,7 +1916,6 @@ public class CertificateRepository extends Repository } } - class CertStatusUpdateThread extends Thread { CertificateRepository _cr = null; IRepository _rr = null; @@ -1965,7 +1967,6 @@ class CertStatusUpdateThread extends Thread { } } - class RetrieveModificationsThread extends Thread { CertificateRepository _cr = null; LDAPSearchResults _results = null; @@ -1992,7 +1993,7 @@ class RetrieveModificationsThread extends Thread { _cr.getModifications(entry); } } catch (LDAPException e) { - CMS.debug("LDAPException: "+e.toString()); + CMS.debug("LDAPException: " + e.toString()); } } else { CMS.debug("_results are null"); diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java b/pki/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java index 65b1039d4..20e40a8e3 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; @@ -37,22 +36,21 @@ import com.netscape.certsrv.dbs.IDBObj; import com.netscape.certsrv.dbs.IDBRegistry; import com.netscape.certsrv.dbs.IFilterConverter; import com.netscape.certsrv.logging.ILogger; - /** * A class represents a registry where all the - * schema (object classes and attribute) information + * schema (object classes and attribute) information * is stored. - * + * * Attribute mappers can be registered with this * registry. - * + * * Given the schema information stored, this registry * has knowledge to convert a Java object into a * LDAPAttributeSet or vice versa. - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class DBRegistry implements IDBRegistry, ISubsystem { @@ -87,17 +85,17 @@ public class DBRegistry implements IDBRegistry, ISubsystem { } /** - * Initializes the internal registery. Connects to the - * data source, and create a pool of connection of which + * Initializes the internal registery. Connects to the + * data source, and create a pool of connection of which * applications can use. Optionally, check the integrity * of the database. */ - public void init(ISubsystem owner, IConfigStore config) - throws EBaseException { + public void init(ISubsystem owner, IConfigStore config) + throws EBaseException { mConfig = config; mConverter = new LdapFilterConverter(mAttrufNames); } - + /** * Retrieves configuration store. */ @@ -128,14 +126,14 @@ public class DBRegistry implements IDBRegistry, ISubsystem { * Registers object class. */ public void registerObjectClass(String className, String ldapNames[]) - throws EDBException { + throws EDBException { try { Class<?> c = Class.forName(className); mOCclassNames.put(className, ldapNames); mOCldapNames.put(sortAndConcate( - ldapNames).toLowerCase(), - new NameAndObject(className, c)); + ldapNames).toLowerCase(), + new NameAndObject(className, c)); } catch (ClassNotFoundException e) { /*LogDoc @@ -145,7 +143,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { * @message DBRegistry: <exception thrown> */ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, - ILogger.LL_FAILURE, CMS.getLogMessage("OPERATION_ERROR", e.toString())); + ILogger.LL_FAILURE, CMS.getLogMessage("OPERATION_ERROR", e.toString())); throw new EDBException( CMS.getUserMessage("CMS_DBS_INVALID_CLASS_NAME", className)); } @@ -161,8 +159,8 @@ public class DBRegistry implements IDBRegistry, ISubsystem { /** * Registers attribute mapper. */ - public void registerAttribute(String ufName, IDBAttrMapper mapper) - throws EDBException { + public void registerAttribute(String ufName, IDBAttrMapper mapper) + throws EDBException { // should not allows 'objectclass' as attribute; it has // special meaning mAttrufNames.put(ufName.toLowerCase(), mapper); @@ -183,6 +181,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { * Creates LDAP-based search filters with help of * registered mappers. * Parses filter from filter string specified in RFC1558. + * * <pre> * <filter> ::= '(' <filtercomp> ')' * <filtercomp> ::= <and> | <or> | <not> | <item> @@ -209,37 +208,37 @@ public class DBRegistry implements IDBRegistry, ISubsystem { return getFilter(filter, mConverter); } - public String getFilter(String filter, IFilterConverter c) - throws EBaseException { + public String getFilter(String filter, IFilterConverter c) + throws EBaseException { String f = filter; f = f.trim(); if (f.startsWith("(") && f.endsWith(")")) { - return "(" + getFilterComp(f.substring(1, + return "(" + getFilterComp(f.substring(1, f.length() - 1), c) + ")"; } else { return getFilterComp(filter, c); } } - private String getFilterComp(String f, IFilterConverter c) - throws EBaseException { + private String getFilterComp(String f, IFilterConverter c) + throws EBaseException { f = f.trim(); - if (f.startsWith("&")) { // AND operation - return "&" + getFilterList(f.substring(1, + if (f.startsWith("&")) { // AND operation + return "&" + getFilterList(f.substring(1, f.length()), c); } else if (f.startsWith("|")) { // OR operation - return "|" + getFilterList(f.substring(1, + return "|" + getFilterList(f.substring(1, f.length()), c); } else if (f.startsWith("!")) { // NOT operation return "!" + getFilter(f.substring(1, f.length()), c); - } else { // item + } else { // item return getFilterItem(f, c); } } - - private String getFilterList(String f, IFilterConverter c) - throws EBaseException { + + private String getFilterList(String f, IFilterConverter c) + throws EBaseException { f = f.trim(); int level = 0; int start = 0; @@ -274,8 +273,8 @@ public class DBRegistry implements IDBRegistry, ISubsystem { /** * So, here we need to separate item into name, op, value. */ - private String getFilterItem(String f, IFilterConverter c) - throws EBaseException { + private String getFilterItem(String f, IFilterConverter c) + throws EBaseException { f = f.trim(); int idx = f.indexOf('='); @@ -318,7 +317,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { if (value.indexOf('*') == -1) { if (type.equals("objectclass")) { String ldapNames[] = (String[]) - mOCclassNames.get(value); + mOCclassNames.get(value); if (ldapNames == null) throw new EDBException( @@ -326,8 +325,8 @@ public class DBRegistry implements IDBRegistry, ISubsystem { String filter = ""; for (int g = 0; g < ldapNames.length; g++) { - filter += "(objectclass=" + - ldapNames[g] + ")"; + filter += "(objectclass=" + + ldapNames[g] + ")"; } return "&" + filter; } else { @@ -341,14 +340,14 @@ public class DBRegistry implements IDBRegistry, ISubsystem { /** * Maps object into LDAP attribute set. */ - public void mapObject(IDBObj parent, String name, Object obj, - LDAPAttributeSet attrs) throws EBaseException { + public void mapObject(IDBObj parent, String name, Object obj, + LDAPAttributeSet attrs) throws EBaseException { IDBAttrMapper mapper = (IDBAttrMapper) mAttrufNames.get( name.toLowerCase()); if (mapper == null) { return; // no mapper found, just skip this attribute - } + } mapper.mapObjectToLDAPAttributeSet(parent, name, obj, attrs); } @@ -358,10 +357,10 @@ public class DBRegistry implements IDBRegistry, ISubsystem { * This method is used for searches, to map the database attributes * to LDAP attributes. */ - public String[] getLDAPAttributes(String attrs[]) - throws EBaseException { + public String[] getLDAPAttributes(String attrs[]) + throws EBaseException { IDBAttrMapper mapper; - + if (attrs == null) return null; Vector<String> v = new Vector<String>(); @@ -391,10 +390,9 @@ public class DBRegistry implements IDBRegistry, ISubsystem { } else { IDBDynAttrMapper matchingDynAttrMapper = null; // check if a dynamic mapper can handle the attribute - for (Iterator<IDBDynAttrMapper> dynMapperIter = mDynAttrMappers.iterator(); - dynMapperIter.hasNext();) { + for (Iterator<IDBDynAttrMapper> dynMapperIter = mDynAttrMappers.iterator(); dynMapperIter.hasNext();) { IDBDynAttrMapper dynAttrMapper = - (IDBDynAttrMapper)dynMapperIter.next(); + (IDBDynAttrMapper) dynMapperIter.next(); if (dynAttrMapper.supportsLDAPAttributeName(attrs[i])) { matchingDynAttrMapper = dynAttrMapper; break; @@ -410,7 +408,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { * @message DBRegistry: <attr> is not registered */ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, - ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_DBS_ATTR_NOT_REGISTER", attrs[i])); + ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_DBS_ATTR_NOT_REGISTER", attrs[i])); throw new EDBException(CMS.getLogMessage("CMSCORE_DBS_ATTR_NOT_REGISTER", attrs[i])); } } @@ -427,8 +425,8 @@ public class DBRegistry implements IDBRegistry, ISubsystem { /** * Creates attribute set from object. */ - public LDAPAttributeSet createLDAPAttributeSet(IDBObj obj) - throws EBaseException { + public LDAPAttributeSet createLDAPAttributeSet(IDBObj obj) + throws EBaseException { Enumeration<String> e = obj.getSerializableAttrNames(); LDAPAttributeSet attrs = new LDAPAttributeSet(); @@ -453,7 +451,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { * Creates object from attribute set. */ public IDBObj createObject(LDAPAttributeSet attrs) - throws EBaseException { + throws EBaseException { // map object class attribute to object LDAPAttribute attr = attrs.getAttribute("objectclass"); @@ -463,7 +461,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { // sort the object class values @SuppressWarnings("unchecked") - Enumeration<String> vals = attr.getStringValues(); + Enumeration<String> vals = attr.getStringValues(); Vector<String> v = new Vector<String>(); while (vals.hasMoreElements()) { @@ -488,15 +486,15 @@ public class DBRegistry implements IDBRegistry, ISubsystem { while (ee.hasMoreElements()) { String oname = (String) ee.nextElement(); IDBAttrMapper mapper = (IDBAttrMapper) - mAttrufNames.get( - oname.toLowerCase()); + mAttrufNames.get( + oname.toLowerCase()); if (mapper == null) { throw new EDBException( CMS.getUserMessage("CMS_DBS_NO_MAPPER_FOUND", oname)); } - mapper.mapLDAPAttributeSetToObject(attrs, - oname, obj); + mapper.mapLDAPAttributeSetToObject(attrs, + oname, obj); } return obj; } catch (Exception e) { @@ -508,7 +506,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { * @message DBRegistry: <attr> is not registered */ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, - ILogger.LL_FAILURE, CMS.getLogMessage("OPERATION_ERROR", e.toString())); + ILogger.LL_FAILURE, CMS.getLogMessage("OPERATION_ERROR", e.toString())); throw new EDBException(CMS.getUserMessage("CMS_DBS_INVALID_ATTRS")); } } @@ -543,7 +541,6 @@ public class DBRegistry implements IDBRegistry, ISubsystem { } } - /** * Just a convenient container class. */ @@ -556,7 +553,7 @@ class NameAndObject { mN = name; mO = o; } - + public String getName() { return mN; } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/DBSSession.java b/pki/base/common/src/com/netscape/cmscore/dbs/DBSSession.java index 5b081d6c2..db2f3c4e7 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/DBSSession.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/DBSSession.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Enumeration; import netscape.ldap.LDAPAttribute; @@ -47,14 +46,13 @@ import com.netscape.certsrv.dbs.Modification; import com.netscape.certsrv.dbs.ModificationSet; import com.netscape.certsrv.logging.ILogger; - /** * A class represents the database session. Operations * can be performed with a session. - * + * * Transaction and Caching support can be integrated * into session. - * + * * @author thomask * @version $Revision$, $Date$ */ @@ -66,7 +64,7 @@ public class DBSSession implements IDBSSession { /** * Constructs a database session. - * + * * @param system the database subsytem * @param c the ldap connection */ @@ -75,7 +73,7 @@ public class DBSSession implements IDBSSession { mConn = c; try { // no limit - mConn.setOption(LDAPv2.SIZELIMIT, Integer.valueOf(0)); + mConn.setOption(LDAPv2.SIZELIMIT, Integer.valueOf(0)); } catch (LDAPException e) { } } @@ -97,18 +95,19 @@ public class DBSSession implements IDBSSession { /** * Adds object to backend database. For example, + * * <PRE> - * session.add("cn=123459,o=certificate repository,o=airius.com", - * certRec); + * session.add("cn=123459,o=certificate repository,o=airius.com", + * certRec); * </PRE> - * + * * @param name the name of the ldap entry * @param obj the DBobj that can be mapped to ldap attrubute set */ public void add(String name, IDBObj obj) throws EBaseException { try { LDAPAttributeSet attrs = mDBSystem.getRegistry( - ).createLDAPAttributeSet(obj); + ).createLDAPAttributeSet(obj); LDAPEntry e = new LDAPEntry(name, attrs); /*LogDoc @@ -118,7 +117,7 @@ public class DBSSession implements IDBSSession { */ mConn.add(e); } catch (LDAPException e) { - if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) + if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) throw new EDBNotAvailException( CMS.getUserMessage("CMS_DBS_INTERNAL_DIR_UNAVAILABLE")); throw new EDBException(CMS.getUserMessage("CMS_DBS_LDAP_OP_FAILURE", @@ -129,7 +128,7 @@ public class DBSSession implements IDBSSession { /** * Reads an object from the database. * all attributes will be returned - * + * * @param name the name of the ldap entry */ public IDBObj read(String name) throws EBaseException { @@ -139,12 +138,12 @@ public class DBSSession implements IDBSSession { /** * Reads an object from the database, and only populates * the selected attributes. - * + * * @param name the name of the ldap entry * @param attrs the attributes to be selected */ public IDBObj read(String name, String attrs[]) - throws EBaseException { + throws EBaseException { try { String ldapattrs[] = null; @@ -173,10 +172,10 @@ public class DBSSession implements IDBSSession { * @message DBSSession: <exception thrown> */ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_INFO, "DBSSession: " + e.toString()); - if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) + if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) throw new EDBNotAvailException( CMS.getUserMessage("CMS_DBS_INTERNAL_DIR_UNAVAILABLE")); - if (e.getLDAPResultCode() == LDAPException.NO_SUCH_OBJECT) + if (e.getLDAPResultCode() == LDAPException.NO_SUCH_OBJECT) throw new EDBRecordNotFoundException( CMS.getUserMessage("CMS_DBS_RECORD_NOT_FOUND")); throw new EDBException(CMS.getUserMessage("CMS_DBS_LDAP_OP_FAILURE", @@ -191,7 +190,7 @@ public class DBSSession implements IDBSSession { try { mConn.delete(name); } catch (LDAPException e) { - if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) + if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) throw new EDBNotAvailException( CMS.getUserMessage("CMS_DBS_INTERNAL_DIR_UNAVAILABLE")); throw new EDBException(CMS.getUserMessage("CMS_DBS_LDAP_OP_FAILURE", @@ -203,25 +202,25 @@ public class DBSSession implements IDBSSession { * Modify an object in the database. */ public void modify(String name, ModificationSet mods) - throws EBaseException { + throws EBaseException { try { LDAPModificationSet ldapMods = new - LDAPModificationSet(); + LDAPModificationSet(); Enumeration<?> e = mods.getModifications(); while (e.hasMoreElements()) { Modification mod = (Modification) - e.nextElement(); + e.nextElement(); LDAPAttributeSet attrs = new LDAPAttributeSet(); mDBSystem.getRegistry().mapObject(null, - mod.getName(), mod.getValue(), attrs); + mod.getName(), mod.getValue(), attrs); Enumeration<?> e0 = attrs.getAttributes(); while (e0.hasMoreElements()) { ldapMods.add(toLdapModOp(mod.getOp()), - (LDAPAttribute) - e0.nextElement()); + (LDAPAttribute) + e0.nextElement()); } } @@ -232,7 +231,7 @@ public class DBSSession implements IDBSSession { */ mConn.modify(name, ldapMods); } catch (LDAPException e) { - if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) + if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) throw new EDBNotAvailException( CMS.getUserMessage("CMS_DBS_INTERNAL_DIR_UNAVAILABLE")); throw new EDBException(CMS.getUserMessage("CMS_DBS_LDAP_OP_FAILURE", @@ -260,16 +259,16 @@ public class DBSSession implements IDBSSession { * filter. */ public IDBSearchResults search(String base, String filter) - throws EBaseException { + throws EBaseException { return search(base, filter, null); } public IDBSearchResults search(String base, String filter, int maxSize) - throws EBaseException { + throws EBaseException { try { String ldapattrs[] = null; String ldapfilter = - mDBSystem.getRegistry().getFilter(filter); + mDBSystem.getRegistry().getFilter(filter); LDAPSearchConstraints cons = new LDAPSearchConstraints(); @@ -281,22 +280,22 @@ public class DBSSession implements IDBSSession { return new DBSearchResults(mDBSystem.getRegistry(), res); } catch (LDAPException e) { - if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) + if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) throw new EDBNotAvailException( CMS.getUserMessage("CMS_DBS_INTERNAL_DIR_UNAVAILABLE")); - // XXX error handling, should not raise exception if - // entry not found + // XXX error handling, should not raise exception if + // entry not found throw new EDBException(CMS.getUserMessage("CMS_DBS_LDAP_OP_FAILURE", e.toString())); } } public IDBSearchResults search(String base, String filter, int maxSize, int timeLimit) - throws EBaseException { + throws EBaseException { try { String ldapattrs[] = null; String ldapfilter = - mDBSystem.getRegistry().getFilter(filter); + mDBSystem.getRegistry().getFilter(filter); LDAPSearchConstraints cons = new LDAPSearchConstraints(); @@ -309,11 +308,11 @@ public class DBSSession implements IDBSSession { return new DBSearchResults(mDBSystem.getRegistry(), res); } catch (LDAPException e) { - if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) + if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) throw new EDBNotAvailException( CMS.getUserMessage("CMS_DBS_INTERNAL_DIR_UNAVAILABLE")); - // XXX error handling, should not raise exception if - // entry not found + // XXX error handling, should not raise exception if + // entry not found throw new EDBException(CMS.getUserMessage("CMS_DBS_LDAP_OP_FAILURE", e.toString())); } @@ -324,7 +323,7 @@ public class DBSSession implements IDBSSession { * filter. */ public IDBSearchResults search(String base, String filter, - String attrs[]) throws EBaseException { + String attrs[]) throws EBaseException { try { String ldapattrs[] = null; @@ -333,7 +332,7 @@ public class DBSSession implements IDBSSession { ).getLDAPAttributes(attrs); } String ldapfilter = - mDBSystem.getRegistry().getFilter(filter); + mDBSystem.getRegistry().getFilter(filter); /*LogDoc * @@ -342,26 +341,26 @@ public class DBSSession implements IDBSSession { */ LDAPSearchConstraints cons = new LDAPSearchConstraints(); - cons.setMaxResults(0); - + cons.setMaxResults(0); + LDAPSearchResults res = mConn.search(base, LDAPv2.SCOPE_ONE, ldapfilter, ldapattrs, false, cons); return new DBSearchResults(mDBSystem.getRegistry(), res); } catch (LDAPException e) { - if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) + if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) throw new EDBNotAvailException( CMS.getUserMessage("CMS_DBS_INTERNAL_DIR_UNAVAILABLE")); - // XXX error handling, should not raise exception if - // entry not found + // XXX error handling, should not raise exception if + // entry not found throw new EDBException(CMS.getUserMessage("CMS_DBS_LDAP_OP_FAILURE", e.toString())); } } public LDAPSearchResults persistentSearch(String base, String filter, String attrs[]) - throws EBaseException { + throws EBaseException { try { String ldapattrs[] = null; if (attrs != null) { @@ -369,9 +368,9 @@ public class DBSSession implements IDBSSession { ).getLDAPAttributes(attrs); } String ldapfilter = - mDBSystem.getRegistry().getFilter(filter); + mDBSystem.getRegistry().getFilter(filter); - Integer version = (Integer)(mConn.getOption(LDAPv2.PROTOCOL_VERSION)); + Integer version = (Integer) (mConn.getOption(LDAPv2.PROTOCOL_VERSION)); // Only version 3 protocol supports persistent search. if (version.intValue() == 2) { @@ -384,22 +383,22 @@ public class DBSSession implements IDBSSession { boolean returnControls = true; boolean isCritical = true; LDAPPersistSearchControl persistCtrl = new - LDAPPersistSearchControl( op, changesOnly, - returnControls, isCritical ); + LDAPPersistSearchControl(op, changesOnly, + returnControls, isCritical); LDAPSearchConstraints cons = new LDAPSearchConstraints(); cons.setBatchSize(0); - cons.setServerControls( persistCtrl ); + cons.setServerControls(persistCtrl); LDAPSearchResults res = mConn.search(base, LDAPv2.SCOPE_ONE, ldapfilter, ldapattrs, false, cons); return res; } catch (LDAPException e) { - if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) + if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) throw new EDBNotAvailException( CMS.getUserMessage("CMS_DBS_INTERNAL_DIR_UNAVAILABLE")); - // XXX error handling, should not raise exception if - // entry not found + // XXX error handling, should not raise exception if + // entry not found throw new EDBException(CMS.getUserMessage("CMS_DBS_LDAP_OP_FAILURE", e.toString())); } @@ -409,7 +408,7 @@ public class DBSSession implements IDBSSession { * Retrieves a list of objects. */ public <T> IDBVirtualList<T> createVirtualList(String base, String filter, - String attrs[]) throws EBaseException { + String attrs[]) throws EBaseException { return new DBVirtualList<T>(mDBSystem.getRegistry(), mConn, base, filter, attrs); } @@ -418,7 +417,7 @@ public class DBSSession implements IDBSSession { * Retrieves a list of objects. */ public <T> IDBVirtualList<T> createVirtualList(String base, String filter, - String attrs[], String sortKey[]) throws EBaseException { + String attrs[], String sortKey[]) throws EBaseException { return new DBVirtualList<T>(mDBSystem.getRegistry(), mConn, base, filter, attrs, sortKey); } @@ -427,7 +426,7 @@ public class DBSSession implements IDBSSession { * Retrieves a list of objects. */ public IDBVirtualList<?> createVirtualList(String base, String filter, - String attrs[], String sortKey) throws EBaseException { + String attrs[], String sortKey) throws EBaseException { return new DBVirtualList<Object>(mDBSystem.getRegistry(), mConn, base, filter, attrs, sortKey); } @@ -436,7 +435,7 @@ public class DBSSession implements IDBSSession { * Retrieves a list of objects. */ public IDBVirtualList<?> createVirtualList(String base, String filter, - String attrs[], String sortKey[], int pageSize) throws EBaseException { + String attrs[], String sortKey[], int pageSize) throws EBaseException { return new DBVirtualList<Object>(mDBSystem.getRegistry(), mConn, base, filter, attrs, sortKey, pageSize); } @@ -445,13 +444,13 @@ public class DBSSession implements IDBSSession { * Retrieves a list of objects. */ public IDBVirtualList<?> createVirtualList(String base, String filter, - String attrs[], String sortKey, int pageSize) throws EBaseException { + String attrs[], String sortKey, int pageSize) throws EBaseException { return new DBVirtualList<Object>(mDBSystem.getRegistry(), mConn, base, filter, attrs, sortKey, pageSize); } public IDBVirtualList<?> createVirtualList(String base, String filter, - String attrs[], String startFrom, String sortKey, int pageSize) throws EBaseException { + String attrs[], String startFrom, String sortKey, int pageSize) throws EBaseException { return new DBVirtualList<Object>(mDBSystem.getRegistry(), mConn, base, filter, attrs, startFrom, sortKey, pageSize); diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/DBSUtil.java b/pki/base/common/src/com/netscape/cmscore/dbs/DBSUtil.java index 123fb8478..7c551b141 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/DBSUtil.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/DBSUtil.java @@ -17,16 +17,13 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - - - /** * A class represents ann attribute mapper that maps * a Java BigInteger object into LDAP attribute, * and vice versa. - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class DBSUtil { 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 8b5098dc3..0621701b0 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/DBSearchResults.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/DBSearchResults.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Enumeration; import netscape.ldap.LDAPEntry; @@ -27,15 +26,14 @@ import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.dbs.IDBRegistry; import com.netscape.certsrv.dbs.IDBSearchResults; import com.netscape.certsrv.logging.ILogger; - /** * A class represents the search results. A search * results object contain a enumeration of * Java objects that are just read from the database. - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class DBSearchResults implements IDBSearchResults { @@ -71,13 +69,13 @@ public class DBSearchResults implements IDBSearchResults { entry = (LDAPEntry) o; return mRegistry.createObject(entry.getAttributeSet()); } else { - if (o instanceof LDAPException) + if (o instanceof LDAPException) ; - // doing nothing because the last object in the search - // results is always LDAPException + // doing nothing because the last object in the search + // results is always LDAPException else mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, - ILogger.LL_FAILURE, "DBSearchResults: result format error class=" + o.getClass().getName()); + ILogger.LL_FAILURE, "DBSearchResults: result format error class=" + o.getClass().getName()); } } catch (Exception e) { @@ -88,7 +86,7 @@ public class DBSearchResults implements IDBSearchResults { * @message DBSearchResults: <exception thrown> */ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, - ILogger.LL_FAILURE, "DBSearchResults: " + e.toString()); + ILogger.LL_FAILURE, "DBSearchResults: " + e.toString()); } return null; } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java b/pki/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java index 3208a23d7..be26c036c 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.math.BigInteger; import java.util.Hashtable; @@ -53,17 +52,16 @@ import com.netscape.cmscore.ldapconn.LdapAuthInfo; import com.netscape.cmscore.ldapconn.LdapBoundConnFactory; import com.netscape.cmscore.ldapconn.LdapConnInfo; - /** * A class represents the database subsystem that manages * the backend data storage. - * + * * This subsystem maintains multiple sessions that allows * operations to be performed, and provide a registry * where all the schema information is stored. - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class DBSubsystem implements IDBSubsystem { @@ -98,40 +96,40 @@ public class DBSubsystem implements IDBSubsystem { private static final String KR_DN = "ou=keyRepository, ou=kra"; private static final String KRA_REQUESTS_DN = "ou=kra, ou=requests"; private static final String REPLICA_DN = "ou=replica"; - private static final String PROP_ENABLE_SERIAL_NUMBER_RECOVERY = - "enableSerialNumberRecovery"; + private static final String PROP_ENABLE_SERIAL_NUMBER_RECOVERY = + "enableSerialNumberRecovery"; // This value is only equal to the next Serial number that the CA's // going to issue when cms just start up or it's just set from console. // It doesn't record the next serial number at other time when cms's // runing not to increase overhead when issuing certs. - private static final String PROP_NEXT_SERIAL_NUMBER = - "nextSerialNumber"; - private static final String PROP_MIN_SERIAL_NUMBER="beginSerialNumber"; + private static final String PROP_NEXT_SERIAL_NUMBER = + "nextSerialNumber"; + private static final String PROP_MIN_SERIAL_NUMBER = "beginSerialNumber"; private static final String PROP_MAX_SERIAL_NUMBER = "endSerialNumber"; - private static final String PROP_NEXT_MIN_SERIAL_NUMBER="nextBeginSerialNumber"; - private static final String PROP_NEXT_MAX_SERIAL_NUMBER ="nextEndSerialNumber"; - private static final String PROP_SERIAL_LOW_WATER_MARK="serialLowWaterMark"; - private static final String PROP_SERIAL_INCREMENT="serialIncrement"; - private static final String PROP_SERIAL_BASEDN="serialDN"; - private static final String PROP_SERIAL_RANGE_DN="serialRangeDN"; - - private static final String PROP_MIN_REQUEST_NUMBER="beginRequestNumber"; - private static final String PROP_MAX_REQUEST_NUMBER="endRequestNumber"; - private static final String PROP_NEXT_MIN_REQUEST_NUMBER="nextBeginRequestNumber"; - private static final String PROP_NEXT_MAX_REQUEST_NUMBER="nextEndRequestNumber"; - private static final String PROP_REQUEST_LOW_WATER_MARK="requestLowWaterMark"; - private static final String PROP_REQUEST_INCREMENT="requestIncrement"; - private static final String PROP_REQUEST_BASEDN="requestDN"; - private static final String PROP_REQUEST_RANGE_DN="requestRangeDN"; - - private static final String PROP_MIN_REPLICA_NUMBER="beginReplicaNumber"; + private static final String PROP_NEXT_MIN_SERIAL_NUMBER = "nextBeginSerialNumber"; + private static final String PROP_NEXT_MAX_SERIAL_NUMBER = "nextEndSerialNumber"; + private static final String PROP_SERIAL_LOW_WATER_MARK = "serialLowWaterMark"; + private static final String PROP_SERIAL_INCREMENT = "serialIncrement"; + private static final String PROP_SERIAL_BASEDN = "serialDN"; + private static final String PROP_SERIAL_RANGE_DN = "serialRangeDN"; + + private static final String PROP_MIN_REQUEST_NUMBER = "beginRequestNumber"; + private static final String PROP_MAX_REQUEST_NUMBER = "endRequestNumber"; + private static final String PROP_NEXT_MIN_REQUEST_NUMBER = "nextBeginRequestNumber"; + private static final String PROP_NEXT_MAX_REQUEST_NUMBER = "nextEndRequestNumber"; + private static final String PROP_REQUEST_LOW_WATER_MARK = "requestLowWaterMark"; + private static final String PROP_REQUEST_INCREMENT = "requestIncrement"; + private static final String PROP_REQUEST_BASEDN = "requestDN"; + private static final String PROP_REQUEST_RANGE_DN = "requestRangeDN"; + + private static final String PROP_MIN_REPLICA_NUMBER = "beginReplicaNumber"; private static final String PROP_MAX_REPLICA_NUMBER = "endReplicaNumber"; - private static final String PROP_NEXT_MIN_REPLICA_NUMBER="nextBeginReplicaNumber"; - private static final String PROP_NEXT_MAX_REPLICA_NUMBER ="nextEndReplicaNumber"; - private static final String PROP_REPLICA_LOW_WATER_MARK="replicaLowWaterMark"; - private static final String PROP_REPLICA_INCREMENT="replicaIncrement"; - private static final String PROP_REPLICA_BASEDN="replicaDN"; - private static final String PROP_REPLICA_RANGE_DN="replicaRangeDN"; + private static final String PROP_NEXT_MIN_REPLICA_NUMBER = "nextBeginReplicaNumber"; + private static final String PROP_NEXT_MAX_REPLICA_NUMBER = "nextEndReplicaNumber"; + private static final String PROP_REPLICA_LOW_WATER_MARK = "replicaLowWaterMark"; + private static final String PROP_REPLICA_INCREMENT = "replicaIncrement"; + private static final String PROP_REPLICA_BASEDN = "replicaDN"; + private static final String PROP_REPLICA_RANGE_DN = "replicaRangeDN"; private static final String PROP_INFINITE_SERIAL_NUMBER = "1000000000"; private static final String PROP_INFINITE_REQUEST_NUMBER = "1000000000"; @@ -140,27 +138,27 @@ public class DBSubsystem implements IDBSubsystem { private static final String PROP_LDAP = "ldap"; private static final String PROP_NEXT_RANGE = "nextRange"; private static final String PROP_ENABLE_SERIAL_MGMT = "enableSerialManagement"; - + // hash keys - private static final String NAME="name"; - private static final String PROP_MIN="min"; - private static final String PROP_MIN_NAME="min_name"; + private static final String NAME = "name"; + private static final String PROP_MIN = "min"; + private static final String PROP_MIN_NAME = "min_name"; private static final String PROP_MAX = "max"; private static final String PROP_MAX_NAME = "max_name"; - private static final String PROP_NEXT_MIN="next_min"; - private static final String PROP_NEXT_MIN_NAME="next_min_name"; + private static final String PROP_NEXT_MIN = "next_min"; + private static final String PROP_NEXT_MIN_NAME = "next_min_name"; private static final String PROP_NEXT_MAX = "next_max"; private static final String PROP_NEXT_MAX_NAME = "next_max_name"; - private static final String PROP_LOW_WATER_MARK="lowWaterMark"; - private static final String PROP_LOW_WATER_MARK_NAME="lowWaterMark_name"; + private static final String PROP_LOW_WATER_MARK = "lowWaterMark"; + private static final String PROP_LOW_WATER_MARK_NAME = "lowWaterMark_name"; private static final String PROP_INCREMENT = "increment"; private static final String PROP_INCREMENT_NAME = "increment_name"; - private static final String PROP_RANGE_DN="rangeDN"; + private static final String PROP_RANGE_DN = "rangeDN"; private static final BigInteger BI_ONE = new BigInteger("1"); private ILogger mLogger = null; - + // singleton enforcement private static IDBSubsystem mInstance = new DBSubsystem(); @@ -170,9 +168,10 @@ public class DBSubsystem implements IDBSubsystem { } /** - * This method is used for unit tests. It allows the underlying instance + * This method is used for unit tests. It allows the underlying instance * to be stubbed out. - * @param dbSubsystem The stubbed out subsystem to override with. + * + * @param dbSubsystem The stubbed out subsystem to override with. */ public static void setInstance(IDBSubsystem dbSubsystem) { mInstance = dbSubsystem; @@ -191,7 +190,7 @@ public class DBSubsystem implements IDBSubsystem { */ public String getId() { return IDBSubsystem.SUB_ID; - } + } /** * Sets subsystem identifier. @@ -214,14 +213,14 @@ public class DBSubsystem implements IDBSubsystem { return mEnableSerialMgmt; } - public void setEnableSerialMgmt(boolean v) - throws EBaseException { + public void setEnableSerialMgmt(boolean v) + throws EBaseException { if (v) { CMS.debug("DBSubsystem: Enabling Serial Number Management"); } else { CMS.debug("DBSubsystem: Disabling Serial Number Management"); } - + mDBConfig.putBoolean(PROP_ENABLE_SERIAL_MGMT, v); IConfigStore rootStore = getOwner().getConfigStore(); rootStore.commit(false); @@ -232,30 +231,29 @@ public class DBSubsystem implements IDBSubsystem { return mNextSerialConfig; } - public void setNextSerialConfig(BigInteger serial) - throws EBaseException { + public void setNextSerialConfig(BigInteger serial) + throws EBaseException { mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, - ILogger.LL_INFO, "DBSubsystem: " + - "Setting next serial number: 0x" + serial.toString(16)); + ILogger.LL_INFO, "DBSubsystem: " + + "Setting next serial number: 0x" + serial.toString(16)); mDBConfig.putString(PROP_NEXT_SERIAL_NUMBER, - serial.toString(16)); + serial.toString(16)); } /** * Gets minimum serial number limit in config file - * - * @param repo repo identifier + * + * @param repo repo identifier * @return min serial number */ - public String getMinSerialConfig(int repo) - { + public String getMinSerialConfig(int repo) { return (String) (mRepos[repo]).get(PROP_MIN); } /** * Gets maximum serial number limit in config file - * - * @param repo repo identifier + * + * @param repo repo identifier * @return max serial number */ public String getMaxSerialConfig(int repo) { @@ -264,41 +262,38 @@ public class DBSubsystem implements IDBSubsystem { /** * Gets minimum serial number limit in next range in config file - * - * @param repo repo identifier + * + * @param repo repo identifier * @return min serial number in next range */ - public String getNextMinSerialConfig(int repo) - { + public String getNextMinSerialConfig(int repo) { String ret = (String) (mRepos[repo]).get(PROP_NEXT_MIN); if (ret.equals("-1")) { return null; - } - else { + } else { return ret; } } /** * Gets maximum serial number limit in next range in config file - * - * @param repo repo identifier + * + * @param repo repo identifier * @return max serial number in next range */ public String getNextMaxSerialConfig(int repo) { String ret = (String) (mRepos[repo]).get(PROP_NEXT_MAX); if (ret.equals("-1")) { return null; - } - else { + } else { return ret; } } /** * Gets low water mark limit in config file - * - * @param repo repo identifier + * + * @param repo repo identifier * @return low water mark */ public String getLowWaterMarkConfig(int repo) { @@ -307,24 +302,23 @@ public class DBSubsystem implements IDBSubsystem { /** * Gets range increment for next range in config file - * - * @param repo repo identifier + * + * @param repo repo identifier * @return range increment */ - public String getIncrementConfig(int repo) - { + public String getIncrementConfig(int repo) { return (String) (mRepos[repo]).get(PROP_INCREMENT); } /** * Sets maximum serial number limit in config file - * - * @param repo repo identifier + * + * @param repo repo identifier * @param serial max serial number - * @exception EBaseException failed to set + * @exception EBaseException failed to set */ - public void setMaxSerialConfig(int repo, String serial) - throws EBaseException { + public void setMaxSerialConfig(int repo, String serial) + throws EBaseException { Hashtable h = mRepos[repo]; CMS.debug("DBSubsystem: Setting max serial number for " + h.get(NAME) + ": " + serial); @@ -339,13 +333,13 @@ public class DBSubsystem implements IDBSubsystem { /** * Sets minimum serial number limit in config file - * - * @param repo repo identifier + * + * @param repo repo identifier * @param serial min serial number - * @exception EBaseException failed to set + * @exception EBaseException failed to set */ - public void setMinSerialConfig(int repo, String serial) - throws EBaseException { + public void setMinSerialConfig(int repo, String serial) + throws EBaseException { Hashtable h = mRepos[repo]; CMS.debug("DBSubsystem: Setting min serial number for " + h.get(NAME) + ": " + serial); @@ -360,13 +354,13 @@ public class DBSubsystem implements IDBSubsystem { /** * Sets maximum serial number limit for next range in config file - * - * @param repo repo identifier + * + * @param repo repo identifier * @param serial max serial number for next range - * @exception EBaseException failed to set + * @exception EBaseException failed to set */ - public void setNextMaxSerialConfig(int repo, String serial) - throws EBaseException { + public void setNextMaxSerialConfig(int repo, String serial) + throws EBaseException { Hashtable h = mRepos[repo]; if (serial == null) { CMS.debug("DBSubsystem: Removing next max " + h.get(NAME) + " number"); @@ -387,13 +381,13 @@ public class DBSubsystem implements IDBSubsystem { /** * Sets minimum serial number limit for next range in config file - * - * @param repo repo identifier + * + * @param repo repo identifier * @param serial min serial number for next range - * @exception EBaseException failed to set + * @exception EBaseException failed to set */ public void setNextMinSerialConfig(int repo, String serial) - throws EBaseException { + throws EBaseException { Hashtable h = mRepos[repo]; if (serial == null) { CMS.debug("DBSubsystem: Removing next min " + h.get(NAME) + " number"); @@ -405,9 +399,9 @@ public class DBSubsystem implements IDBSubsystem { IConfigStore rootStore = getOwner().getConfigStore(); rootStore.commit(false); if (serial == null) { - Object o2 = h.remove(PROP_NEXT_MIN); + Object o2 = h.remove(PROP_NEXT_MIN); } else { - h.put(PROP_NEXT_MIN, serial); + h.put(PROP_NEXT_MIN, serial); } mRepos[repo] = h; } @@ -416,8 +410,8 @@ public class DBSubsystem implements IDBSubsystem { * Gets start of next range from database. * Increments the nextRange attribute and allocates * this range to the current instance by creating a pkiRange object. - * - * @param repo repo identifier + * + * @param repo repo identifier * @return start of next range */ public String getNextRange(int repo) { @@ -430,28 +424,28 @@ public class DBSubsystem implements IDBSubsystem { String rangeDN = (String) h.get(PROP_RANGE_DN) + "," + mBaseDN; LDAPEntry entry = conn.read(dn); - LDAPAttribute attr = entry.getAttribute(PROP_NEXT_RANGE); + LDAPAttribute attr = entry.getAttribute(PROP_NEXT_RANGE); nextRange = (String) attr.getStringValues().nextElement(); BigInteger nextRangeNo = new BigInteger(nextRange); BigInteger incrementNo = new BigInteger((String) h.get(PROP_INCREMENT)); // To make sure attrNextRange always increments, first delete the current value and then // increment. Two operations in the same transaction - LDAPAttribute attrNextRange = new LDAPAttribute(PROP_NEXT_RANGE, nextRangeNo.add(incrementNo).toString()); - LDAPModification [] mods = { - new LDAPModification( LDAPModification.DELETE, attr), - new LDAPModification( LDAPModification.ADD, attrNextRange ) }; - conn.modify( dn, mods ); + LDAPAttribute attrNextRange = new LDAPAttribute(PROP_NEXT_RANGE, nextRangeNo.add(incrementNo).toString()); + LDAPModification[] mods = { + new LDAPModification(LDAPModification.DELETE, attr), + new LDAPModification(LDAPModification.ADD, attrNextRange) }; + conn.modify(dn, mods); // Add new range object String endRange = nextRangeNo.add(incrementNo).subtract(BI_ONE).toString(); LDAPAttributeSet attrs = new LDAPAttributeSet(); attrs.add(new LDAPAttribute("objectClass", "top")); attrs.add(new LDAPAttribute("objectClass", "pkiRange")); - attrs.add(new LDAPAttribute("beginRange" , nextRange)); - attrs.add(new LDAPAttribute("endRange" , endRange)); + attrs.add(new LDAPAttribute("beginRange", nextRange)); + attrs.add(new LDAPAttribute("endRange", endRange)); attrs.add(new LDAPAttribute("cn", nextRange)); - attrs.add(new LDAPAttribute("host", CMS.getEESSLHost())); + attrs.add(new LDAPAttribute("host", CMS.getEESSLHost())); attrs.add(new LDAPAttribute("securePort", CMS.getEESSLPort())); String dn2 = "cn=" + nextRange + "," + rangeDN; LDAPEntry rangeEntry = new LDAPEntry(dn2, attrs); @@ -462,12 +456,11 @@ public class DBSubsystem implements IDBSubsystem { nextRange = null; } finally { try { - if ((conn != null) && (mLdapConnFactory!= null)) { + if ((conn != null) && (mLdapConnFactory != null)) { CMS.debug("Releasing ldap connection"); mLdapConnFactory.returnConn(conn); } - } - catch (Exception e) { + } catch (Exception e) { CMS.debug("Error releasing the ldap connection" + e.toString()); } } @@ -477,29 +470,28 @@ public class DBSubsystem implements IDBSubsystem { /** * Determines if a range conflict has been observed in database. * If so, delete the conflict entry and remove the next range. - * When the next number is requested, if the number of certs is still + * When the next number is requested, if the number of certs is still * below the low water mark, then a new range will be requested. * - * @param repo repo identifier + * @param repo repo identifier * @return true if range conflict, false otherwise */ - public boolean hasRangeConflict(int repo) - { + public boolean hasRangeConflict(int repo) { LDAPConnection conn = null; boolean conflict = false; try { String nextRangeStart = getNextMinSerialConfig(repo); - if (nextRangeStart == null) { + if (nextRangeStart == null) { return false; } Hashtable h = mRepos[repo]; conn = mLdapConnFactory.getConn(); String rangedn = (String) h.get(PROP_RANGE_DN) + "," + mBaseDN; String filter = "(&(nsds5ReplConflict=*)(objectClass=pkiRange)(host= " + - CMS.getEESSLHost() + ")(SecurePort=" + CMS.getEESSLPort() + - ")(beginRange=" + nextRangeStart + "))"; + CMS.getEESSLHost() + ")(SecurePort=" + CMS.getEESSLPort() + + ")(beginRange=" + nextRangeStart + "))"; LDAPSearchResults results = conn.search(rangedn, LDAPv3.SCOPE_SUB, - filter, null, false); + filter, null, false); while (results.hasMoreElements()) { conflict = true; @@ -513,12 +505,11 @@ public class DBSubsystem implements IDBSubsystem { e.printStackTrace(); } finally { try { - if ((conn != null) && (mLdapConnFactory!= null)) { + if ((conn != null) && (mLdapConnFactory != null)) { CMS.debug("Releasing ldap connection"); mLdapConnFactory.returnConn(conn); } - } - catch (Exception e) { + } catch (Exception e) { CMS.debug("Error releasing the ldap connection" + e.toString()); } } @@ -530,14 +521,13 @@ public class DBSubsystem implements IDBSubsystem { } /** - * Initializes the internal registery. Connects to the - * data source, and create a pool of connection of which + * Initializes the internal registery. Connects to the + * data source, and create a pool of connection of which * applications can use. Optionally, check the integrity * of the database. */ - public void init(ISubsystem owner, IConfigStore config) - throws EBaseException { - + public void init(ISubsystem owner, IConfigStore config) + throws EBaseException { mLogger = CMS.getLogger(); mDBConfig = config; @@ -548,110 +538,109 @@ public class DBSubsystem implements IDBSubsystem { try { mBaseDN = mConfig.getString(PROP_BASEDN, "o=NetscapeCertificateServer"); - mOwner = owner; + mOwner = owner; mNextSerialConfig = new BigInteger(mDBConfig.getString( - PROP_NEXT_SERIAL_NUMBER, "0"), 16); + PROP_NEXT_SERIAL_NUMBER, "0"), 16); mEnableSerialMgmt = mDBConfig.getBoolean(PROP_ENABLE_SERIAL_MGMT, false); // populate the certs hash entry Hashtable certs = new Hashtable(); certs.put(NAME, "certs"); - certs.put(PROP_BASEDN, mDBConfig.getString(PROP_SERIAL_BASEDN,"")); + certs.put(PROP_BASEDN, mDBConfig.getString(PROP_SERIAL_BASEDN, "")); certs.put(PROP_RANGE_DN, mDBConfig.getString(PROP_SERIAL_RANGE_DN, "")); certs.put(PROP_MIN_NAME, PROP_MIN_SERIAL_NUMBER); certs.put(PROP_MIN, mDBConfig.getString( - PROP_MIN_SERIAL_NUMBER, "0")); + PROP_MIN_SERIAL_NUMBER, "0")); certs.put(PROP_MAX_NAME, PROP_MAX_SERIAL_NUMBER); certs.put(PROP_MAX, mDBConfig.getString( - PROP_MAX_SERIAL_NUMBER, PROP_INFINITE_SERIAL_NUMBER)); + PROP_MAX_SERIAL_NUMBER, PROP_INFINITE_SERIAL_NUMBER)); certs.put(PROP_NEXT_MIN_NAME, PROP_NEXT_MIN_SERIAL_NUMBER); certs.put(PROP_NEXT_MIN, mDBConfig.getString( - PROP_NEXT_MIN_SERIAL_NUMBER, "-1")); + PROP_NEXT_MIN_SERIAL_NUMBER, "-1")); certs.put(PROP_NEXT_MAX_NAME, PROP_NEXT_MAX_SERIAL_NUMBER); certs.put(PROP_NEXT_MAX, mDBConfig.getString( - PROP_NEXT_MAX_SERIAL_NUMBER, "-1")); + PROP_NEXT_MAX_SERIAL_NUMBER, "-1")); certs.put(PROP_LOW_WATER_MARK_NAME, PROP_SERIAL_LOW_WATER_MARK); certs.put(PROP_LOW_WATER_MARK, mDBConfig.getString( - PROP_SERIAL_LOW_WATER_MARK, "5000")); + PROP_SERIAL_LOW_WATER_MARK, "5000")); certs.put(PROP_INCREMENT_NAME, PROP_SERIAL_INCREMENT); certs.put(PROP_INCREMENT, mDBConfig.getString( - PROP_SERIAL_INCREMENT, PROP_INFINITE_SERIAL_NUMBER)); + PROP_SERIAL_INCREMENT, PROP_INFINITE_SERIAL_NUMBER)); - mRepos[CERTS]=certs; + mRepos[CERTS] = certs; // populate the requests hash entry Hashtable requests = new Hashtable(); requests.put(NAME, "requests"); - requests.put(PROP_BASEDN, mDBConfig.getString(PROP_REQUEST_BASEDN,"")); + requests.put(PROP_BASEDN, mDBConfig.getString(PROP_REQUEST_BASEDN, "")); requests.put(PROP_RANGE_DN, mDBConfig.getString(PROP_REQUEST_RANGE_DN, "")); requests.put(PROP_MIN_NAME, PROP_MIN_REQUEST_NUMBER); requests.put(PROP_MIN, mDBConfig.getString( - PROP_MIN_REQUEST_NUMBER, "0")); + PROP_MIN_REQUEST_NUMBER, "0")); requests.put(PROP_MAX_NAME, PROP_MAX_REQUEST_NUMBER); requests.put(PROP_MAX, mDBConfig.getString( - PROP_MAX_REQUEST_NUMBER, PROP_INFINITE_REQUEST_NUMBER)); + PROP_MAX_REQUEST_NUMBER, PROP_INFINITE_REQUEST_NUMBER)); requests.put(PROP_NEXT_MIN_NAME, PROP_NEXT_MIN_REQUEST_NUMBER); requests.put(PROP_NEXT_MIN, mDBConfig.getString( - PROP_NEXT_MIN_REQUEST_NUMBER, "-1")); + PROP_NEXT_MIN_REQUEST_NUMBER, "-1")); requests.put(PROP_NEXT_MAX_NAME, PROP_NEXT_MAX_REQUEST_NUMBER); requests.put(PROP_NEXT_MAX, mDBConfig.getString( - PROP_NEXT_MAX_REQUEST_NUMBER, "-1")); + PROP_NEXT_MAX_REQUEST_NUMBER, "-1")); requests.put(PROP_LOW_WATER_MARK_NAME, PROP_REQUEST_LOW_WATER_MARK); requests.put(PROP_LOW_WATER_MARK, mDBConfig.getString( - PROP_REQUEST_LOW_WATER_MARK, "5000")); + PROP_REQUEST_LOW_WATER_MARK, "5000")); requests.put(PROP_INCREMENT_NAME, PROP_REQUEST_INCREMENT); requests.put(PROP_INCREMENT, mDBConfig.getString( - PROP_REQUEST_INCREMENT, PROP_INFINITE_REQUEST_NUMBER)); + PROP_REQUEST_INCREMENT, PROP_INFINITE_REQUEST_NUMBER)); mRepos[REQUESTS] = requests; // populate replica ID hash entry Hashtable replicaID = new Hashtable(); replicaID.put(NAME, "requests"); - replicaID.put(PROP_BASEDN, mDBConfig.getString(PROP_REPLICA_BASEDN,"")); + replicaID.put(PROP_BASEDN, mDBConfig.getString(PROP_REPLICA_BASEDN, "")); replicaID.put(PROP_RANGE_DN, mDBConfig.getString(PROP_REPLICA_RANGE_DN, "")); replicaID.put(PROP_MIN_NAME, PROP_MIN_REPLICA_NUMBER); replicaID.put(PROP_MIN, mDBConfig.getString( - PROP_MIN_REPLICA_NUMBER, "1")); + PROP_MIN_REPLICA_NUMBER, "1")); replicaID.put(PROP_MAX_NAME, PROP_MAX_REPLICA_NUMBER); replicaID.put(PROP_MAX, mDBConfig.getString( - PROP_MAX_REPLICA_NUMBER, PROP_INFINITE_REPLICA_NUMBER)); + PROP_MAX_REPLICA_NUMBER, PROP_INFINITE_REPLICA_NUMBER)); replicaID.put(PROP_NEXT_MIN_NAME, PROP_NEXT_MIN_REPLICA_NUMBER); replicaID.put(PROP_NEXT_MIN, mDBConfig.getString( - PROP_NEXT_MIN_REPLICA_NUMBER, "-1")); + PROP_NEXT_MIN_REPLICA_NUMBER, "-1")); replicaID.put(PROP_NEXT_MAX_NAME, PROP_NEXT_MAX_REPLICA_NUMBER); replicaID.put(PROP_NEXT_MAX, mDBConfig.getString( - PROP_NEXT_MAX_REPLICA_NUMBER, "-1")); + PROP_NEXT_MAX_REPLICA_NUMBER, "-1")); replicaID.put(PROP_LOW_WATER_MARK_NAME, PROP_REPLICA_LOW_WATER_MARK); replicaID.put(PROP_LOW_WATER_MARK, mDBConfig.getString( - PROP_REPLICA_LOW_WATER_MARK, "10")); + PROP_REPLICA_LOW_WATER_MARK, "10")); replicaID.put(PROP_INCREMENT_NAME, PROP_REPLICA_INCREMENT); replicaID.put(PROP_INCREMENT, mDBConfig.getString( - PROP_REPLICA_INCREMENT, PROP_INFINITE_REPLICA_NUMBER)); + PROP_REPLICA_INCREMENT, PROP_INFINITE_REPLICA_NUMBER)); mRepos[REPLICA_ID] = replicaID; - // initialize registry mRegistry = new DBRegistry(); mRegistry.init(this, null); @@ -688,7 +677,7 @@ public class DBSubsystem implements IDBSubsystem { try { // registers CMS database attributes IDBRegistry reg = getRegistry(); - + String certRecordOC[] = new String[2]; certRecordOC[0] = CertDBSchema.LDAP_OC_TOP; @@ -696,61 +685,61 @@ public class DBSubsystem implements IDBSubsystem { if (!reg.isObjectClassRegistered(CertRecord.class.getName())) { reg.registerObjectClass(CertRecord.class.getName(), - certRecordOC); + certRecordOC); } if (!reg.isAttributeRegistered(CertRecord.ATTR_ID)) { reg.registerAttribute(CertRecord.ATTR_ID, new - BigIntegerMapper(CertDBSchema.LDAP_ATTR_SERIALNO)); + BigIntegerMapper(CertDBSchema.LDAP_ATTR_SERIALNO)); } if (!reg.isAttributeRegistered(CertRecord.ATTR_META_INFO)) { reg.registerAttribute(CertRecord.ATTR_META_INFO, new - MetaInfoMapper(CertDBSchema.LDAP_ATTR_META_INFO)); + MetaInfoMapper(CertDBSchema.LDAP_ATTR_META_INFO)); } if (!reg.isAttributeRegistered(CertRecord.ATTR_REVO_INFO)) { reg.registerAttribute(CertRecord.ATTR_REVO_INFO, new - RevocationInfoMapper()); + RevocationInfoMapper()); } if (!reg.isAttributeRegistered(CertRecord.ATTR_X509CERT)) { reg.registerAttribute(CertRecord.ATTR_X509CERT, new - X509CertImplMapper()); + X509CertImplMapper()); } if (!reg.isAttributeRegistered(CertRecord.ATTR_CERT_STATUS)) { reg.registerAttribute(CertRecord.ATTR_CERT_STATUS, new - StringMapper(CertDBSchema.LDAP_ATTR_CERT_STATUS)); + StringMapper(CertDBSchema.LDAP_ATTR_CERT_STATUS)); } if (!reg.isAttributeRegistered(CertRecord.ATTR_AUTO_RENEW)) { reg.registerAttribute(CertRecord.ATTR_AUTO_RENEW, new - StringMapper(CertDBSchema.LDAP_ATTR_AUTO_RENEW)); + StringMapper(CertDBSchema.LDAP_ATTR_AUTO_RENEW)); } if (!reg.isAttributeRegistered(CertRecord.ATTR_CREATE_TIME)) { reg.registerAttribute(CertRecord.ATTR_CREATE_TIME, new - DateMapper(CertDBSchema.LDAP_ATTR_CREATE_TIME)); + DateMapper(CertDBSchema.LDAP_ATTR_CREATE_TIME)); } if (!reg.isAttributeRegistered(CertRecord.ATTR_MODIFY_TIME)) { reg.registerAttribute(CertRecord.ATTR_MODIFY_TIME, new - DateMapper(CertDBSchema.LDAP_ATTR_MODIFY_TIME)); + DateMapper(CertDBSchema.LDAP_ATTR_MODIFY_TIME)); } if (!reg.isAttributeRegistered(CertRecord.ATTR_ISSUED_BY)) { reg.registerAttribute(CertRecord.ATTR_ISSUED_BY, new - StringMapper(CertDBSchema.LDAP_ATTR_ISSUED_BY)); + StringMapper(CertDBSchema.LDAP_ATTR_ISSUED_BY)); } if (!reg.isAttributeRegistered(CertRecord.ATTR_REVOKED_BY)) { reg.registerAttribute(CertRecord.ATTR_REVOKED_BY, new - StringMapper(CertDBSchema.LDAP_ATTR_REVOKED_BY)); + StringMapper(CertDBSchema.LDAP_ATTR_REVOKED_BY)); } if (!reg.isAttributeRegistered(CertRecord.ATTR_REVOKED_ON)) { reg.registerAttribute(CertRecord.ATTR_REVOKED_ON, new - DateMapper(CertDBSchema.LDAP_ATTR_REVOKED_ON)); + DateMapper(CertDBSchema.LDAP_ATTR_REVOKED_ON)); } if (!reg.isAttributeRegistered(CertificateValidity.NOT_AFTER)) { reg.registerAttribute(CertificateValidity.NOT_AFTER, new - DateMapper(CertDBSchema.LDAP_ATTR_NOT_AFTER)); + DateMapper(CertDBSchema.LDAP_ATTR_NOT_AFTER)); } if (!reg.isAttributeRegistered(CertificateValidity.NOT_BEFORE)) { reg.registerAttribute(CertificateValidity.NOT_BEFORE, new - DateMapper(CertDBSchema.LDAP_ATTR_NOT_BEFORE)); + DateMapper(CertDBSchema.LDAP_ATTR_NOT_BEFORE)); } String crlRecordOC[] = new String[2]; @@ -758,54 +747,54 @@ public class DBSubsystem implements IDBSubsystem { crlRecordOC[0] = CRLDBSchema.LDAP_OC_TOP; crlRecordOC[1] = CRLDBSchema.LDAP_OC_CRL_RECORD; reg.registerObjectClass(CRLIssuingPointRecord.class.getName(), - crlRecordOC); + crlRecordOC); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_ID, new - StringMapper(CRLDBSchema.LDAP_ATTR_CRL_ID)); + StringMapper(CRLDBSchema.LDAP_ATTR_CRL_ID)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_CRL_NUMBER, new - BigIntegerMapper(CRLDBSchema.LDAP_ATTR_CRL_NUMBER)); + BigIntegerMapper(CRLDBSchema.LDAP_ATTR_CRL_NUMBER)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_DELTA_NUMBER, new - BigIntegerMapper(CRLDBSchema.LDAP_ATTR_DELTA_NUMBER)); + BigIntegerMapper(CRLDBSchema.LDAP_ATTR_DELTA_NUMBER)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_CRL_SIZE, new - LongMapper(CRLDBSchema.LDAP_ATTR_CRL_SIZE)); + LongMapper(CRLDBSchema.LDAP_ATTR_CRL_SIZE)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_DELTA_SIZE, new - LongMapper(CRLDBSchema.LDAP_ATTR_DELTA_SIZE)); + LongMapper(CRLDBSchema.LDAP_ATTR_DELTA_SIZE)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_THIS_UPDATE, new - DateMapper(CRLDBSchema.LDAP_ATTR_THIS_UPDATE)); + DateMapper(CRLDBSchema.LDAP_ATTR_THIS_UPDATE)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_NEXT_UPDATE, new - DateMapper(CRLDBSchema.LDAP_ATTR_NEXT_UPDATE)); + DateMapper(CRLDBSchema.LDAP_ATTR_NEXT_UPDATE)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_FIRST_UNSAVED, new - StringMapper(CRLDBSchema.LDAP_ATTR_FIRST_UNSAVED)); + StringMapper(CRLDBSchema.LDAP_ATTR_FIRST_UNSAVED)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_CRL, new - ByteArrayMapper(CRLDBSchema.LDAP_ATTR_CRL)); + ByteArrayMapper(CRLDBSchema.LDAP_ATTR_CRL)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_DELTA_CRL, new - ByteArrayMapper(CRLDBSchema.LDAP_ATTR_DELTA_CRL)); + ByteArrayMapper(CRLDBSchema.LDAP_ATTR_DELTA_CRL)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_CA_CERT, new - ByteArrayMapper(CRLDBSchema.LDAP_ATTR_CA_CERT)); + ByteArrayMapper(CRLDBSchema.LDAP_ATTR_CA_CERT)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_CRL_CACHE, new - ObjectStreamMapper(CRLDBSchema.LDAP_ATTR_CRL_CACHE)); + ObjectStreamMapper(CRLDBSchema.LDAP_ATTR_CRL_CACHE)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_REVOKED_CERTS, new - ObjectStreamMapper(CRLDBSchema.LDAP_ATTR_REVOKED_CERTS)); + ObjectStreamMapper(CRLDBSchema.LDAP_ATTR_REVOKED_CERTS)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_UNREVOKED_CERTS, new - ObjectStreamMapper(CRLDBSchema.LDAP_ATTR_UNREVOKED_CERTS)); + ObjectStreamMapper(CRLDBSchema.LDAP_ATTR_UNREVOKED_CERTS)); reg.registerAttribute(ICRLIssuingPointRecord.ATTR_EXPIRED_CERTS, new - ObjectStreamMapper(CRLDBSchema.LDAP_ATTR_EXPIRED_CERTS)); + ObjectStreamMapper(CRLDBSchema.LDAP_ATTR_EXPIRED_CERTS)); if (!reg.isObjectClassRegistered( - RepositoryRecord.class.getName())) { + RepositoryRecord.class.getName())) { String repRecordOC[] = new String[2]; repRecordOC[0] = RepositorySchema.LDAP_OC_TOP; repRecordOC[1] = RepositorySchema.LDAP_OC_REPOSITORY; reg.registerObjectClass( - RepositoryRecord.class.getName(), repRecordOC); + RepositoryRecord.class.getName(), repRecordOC); } if (!reg.isAttributeRegistered(IRepositoryRecord.ATTR_SERIALNO)) { reg.registerAttribute(IRepositoryRecord.ATTR_SERIALNO, - new BigIntegerMapper(RepositorySchema.LDAP_ATTR_SERIALNO)); + new BigIntegerMapper(RepositorySchema.LDAP_ATTR_SERIALNO)); } if (!reg.isAttributeRegistered(IRepositoryRecord.ATTR_PUB_STATUS)) { reg.registerAttribute(IRepositoryRecord.ATTR_PUB_STATUS, - new StringMapper(RepositorySchema.LDAP_ATTR_PUB_STATUS)); + new StringMapper(RepositorySchema.LDAP_ATTR_PUB_STATUS)); } } catch (EBaseException e) { @@ -820,7 +809,7 @@ public class DBSubsystem implements IDBSubsystem { */ public void startup() throws EBaseException { } - + /** * Retrieves configuration store. */ @@ -868,9 +857,9 @@ public class DBSubsystem implements IDBSubsystem { * @message DBSubsystem: <exception thrown> */ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, - ILogger.LL_FAILURE, CMS.getLogMessage("OPERATION_ERROR", e.toString())); + ILogger.LL_FAILURE, CMS.getLogMessage("OPERATION_ERROR", e.toString())); } - if (mRegistry != null) + if (mRegistry != null) mRegistry.shutdown(); } @@ -905,11 +894,11 @@ public class DBSubsystem implements IDBSubsystem { LDAPAttributeSchema.cis, false); userType.add(conn); } - + // create new objectclass: cmsuser dirSchema.fetchSchema(conn); LDAPObjectClassSchema newObjClass = dirSchema.getObjectClass("cmsuser"); - String[] requiredAttrs = {"usertype"}; + String[] requiredAttrs = { "usertype" }; String[] optionalAttrs = new String[0]; if (newObjClass == null) { @@ -932,21 +921,21 @@ public class DBSubsystem implements IDBSubsystem { * * @phase create db session */ - mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, - CMS.getLogMessage("CMSCORE_DBS_CONN_ERROR", e.toString())); + mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, + CMS.getLogMessage("CMSCORE_DBS_CONN_ERROR", e.toString())); throw new EDBException( CMS.getUserMessage("CMS_DBS_CONNECT_LDAP_FAILED", e.toString())); } catch (LDAPException e) { if (e.getLDAPResultCode() != 20) { mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, - CMS.getLogMessage("CMSCORE_DBS_SCHEMA_ERROR", e.toString())); + CMS.getLogMessage("CMSCORE_DBS_SCHEMA_ERROR", e.toString())); throw new EDBException( CMS.getUserMessage("CMS_DBS_ADD_ENTRY_FAILED", e.toString())); } } catch (EBaseException e) { - mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, - CMS.getLogMessage("CMSCORE_DBS_CONF_ERROR", - e.toString())); + mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, + CMS.getLogMessage("CMSCORE_DBS_CONF_ERROR", + e.toString())); } return new DBSSession(this, conn); } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java b/pki/base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java index ddec63cef..b9f338c43 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Arrays; import java.util.Vector; @@ -38,12 +37,11 @@ import com.netscape.certsrv.dbs.IDBVirtualList; import com.netscape.certsrv.dbs.IElementProcessor; import com.netscape.certsrv.logging.ILogger; - /** * A class represents a virtual list of search results. * Note that this class must be used with DS4.0. - * - * @author thomask + * + * @author thomask * @author mzhao * @version $Revision$, $Date$ */ @@ -71,17 +69,17 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { // the index of the first entry returned private int mSelectedIndex = 0; private int mJumpToIndex = 0; - private int mJumpToInitialIndex = 0; // Initial index hit in jumpto operation - private int mJumpToDirection = 1; // Do we proceed forward or backwards - private String mJumpTo = null; // Determines if this is the jumpto case + private int mJumpToInitialIndex = 0; // Initial index hit in jumpto operation + private int mJumpToDirection = 1; // Do we proceed forward or backwards + private String mJumpTo = null; // Determines if this is the jumpto case private ILogger mLogger = CMS.getLogger(); /** - * Constructs a virtual list. + * Constructs a virtual list. * Be sure to setPageSize() later if your pageSize is not the default 10 * Be sure to setSortKey() before fetchs - * + * * param registry the registry of attribute mappers * param c the ldap connection. It has to be version 3 and upper * param base the base distinguished name to search from @@ -89,18 +87,18 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { * param attrs list of attributes that you want returned in the search results */ public DBVirtualList(IDBRegistry registry, LDAPConnection c, - String base, String filter, String attrs[]) throws EBaseException { + String base, String filter, String attrs[]) throws EBaseException { mRegistry = registry; mFilter = filter; mBase = base; mAttrs = attrs; - CMS.debug( "In DBVirtualList filter attrs filter: " + filter - + " attrs: " + Arrays.toString( attrs ) ); + CMS.debug("In DBVirtualList filter attrs filter: " + filter + + " attrs: " + Arrays.toString(attrs)); mPageControls = new LDAPControl[2]; try { mConn = (LDAPConnection) c.clone(); } catch (Exception e) { - throw new EBaseException(CMS.getUserMessage("CMS_BASE_CONN_FAILED", + throw new EBaseException(CMS.getUserMessage("CMS_BASE_CONN_FAILED", e.toString())); } } @@ -108,7 +106,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { /** * Constructs a virtual list. * Be sure to setPageSize() later if your pageSize is not the default 10 - * + * * param registry the registry of attribute mappers * param c the ldap connection. It has to be version 3 and upper * param base the base distinguished name to search from @@ -117,17 +115,17 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { * param sortKey the attributes to sort by */ public DBVirtualList(IDBRegistry registry, LDAPConnection c, - String base, String filter, String attrs[], String sortKey[]) - throws EBaseException { + String base, String filter, String attrs[], String sortKey[]) + throws EBaseException { - CMS.debug( "In DBVirtualList filter attrs sotrKey[] filter: " + filter - + " attrs: " + Arrays.toString( attrs ) ); + CMS.debug("In DBVirtualList filter attrs sotrKey[] filter: " + filter + + " attrs: " + Arrays.toString(attrs)); mRegistry = registry; mFilter = filter; try { mConn = (LDAPConnection) c.clone(); } catch (Exception e) { - throw new EBaseException(CMS.getUserMessage("CMS_BASE_CONN_FAILED", + throw new EBaseException(CMS.getUserMessage("CMS_BASE_CONN_FAILED", e.toString())); } mBase = base; @@ -139,7 +137,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { /** * Constructs a virtual list. * Be sure to setPageSize() later if your pageSize is not the default 10 - * + * * param registry the registry of attribute mappers * param c the ldap connection. It has to be version 3 and upper * param base the base distinguished name to search from @@ -148,16 +146,16 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { * param sortKey the attribute to sort by */ public DBVirtualList(IDBRegistry registry, LDAPConnection c, - String base, String filter, String attrs[], String sortKey) - throws EBaseException { + String base, String filter, String attrs[], String sortKey) + throws EBaseException { - CMS.debug( "In DBVirtualList filter attrs sortKey filter: " + filter + " attrs: " + Arrays.toString( attrs ) ); + CMS.debug("In DBVirtualList filter attrs sortKey filter: " + filter + " attrs: " + Arrays.toString(attrs)); mRegistry = registry; mFilter = filter; try { mConn = (LDAPConnection) c.clone(); } catch (Exception e) { - throw new EBaseException(CMS.getUserMessage("CMS_BASE_CONN_FAILED", + throw new EBaseException(CMS.getUserMessage("CMS_BASE_CONN_FAILED", e.toString())); } mBase = base; @@ -168,7 +166,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { /** * Constructs a virtual list. - * + * * param registry the registry of attribute mappers * param c the ldap connection. It has to be version 3 and upper * param base the base distinguished name to search from @@ -176,21 +174,21 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { * param attrs list of attributes that you want returned in the search results * param sortKey the attributes to sort by * param pageSize the size of a page. There is a 3*pageSize buffer maintained so - * pageUp and pageDown won't invoke fetch from ldap server + * pageUp and pageDown won't invoke fetch from ldap server */ public DBVirtualList(IDBRegistry registry, LDAPConnection c, - String base, String filter, String attrs[], String sortKey[], - int pageSize) throws EBaseException { + String base, String filter, String attrs[], String sortKey[], + int pageSize) throws EBaseException { - CMS.debug( "In DBVirtualList filter attrs sortKey[] pageSize filter: " - + filter + " attrs: " + Arrays.toString( attrs ) - + " pageSize " + pageSize ); + CMS.debug("In DBVirtualList filter attrs sortKey[] pageSize filter: " + + filter + " attrs: " + Arrays.toString(attrs) + + " pageSize " + pageSize); mRegistry = registry; mFilter = filter; try { mConn = (LDAPConnection) c.clone(); } catch (Exception e) { - throw new EBaseException(CMS.getUserMessage("CMS_BASE_CONN_FAILED", + throw new EBaseException(CMS.getUserMessage("CMS_BASE_CONN_FAILED", e.toString())); } mBase = base; @@ -202,7 +200,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { /** * Constructs a virtual list. - * + * * param registry the registry of attribute mappers * param c the ldap connection. It has to be version 3 and upper * param base the base distinguished name to search from @@ -210,15 +208,15 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { * param attrs list of attributes that you want returned in the search results * param sortKey the attribute to sort by * param pageSize the size of a page. There is a 3*pageSize buffer maintained so - * pageUp and pageDown won't invoke fetch from ldap server + * pageUp and pageDown won't invoke fetch from ldap server */ public DBVirtualList(IDBRegistry registry, LDAPConnection c, - String base, String filter, String attrs[], String sortKey, - int pageSize) throws EBaseException { + String base, String filter, String attrs[], String sortKey, + int pageSize) throws EBaseException { - CMS.debug( "In DBVirtualList filter attrs sortKey pageSize filter: " - + filter + " attrs: " + Arrays.toString( attrs ) - + " pageSize " + pageSize ); + CMS.debug("In DBVirtualList filter attrs sortKey pageSize filter: " + + filter + " attrs: " + Arrays.toString(attrs) + + " pageSize " + pageSize); mRegistry = registry; mFilter = filter; try { @@ -235,20 +233,20 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { } public DBVirtualList(IDBRegistry registry, LDAPConnection c, - String base, String filter, String attrs[], - String startFrom, String sortKey, - int pageSize) throws EBaseException { - - CMS.debug( "In DBVirtualList filter attrs startFrom sortKey pageSize " - + "filter: " + filter - + " attrs: " + Arrays.toString( attrs ) - + " pageSize " + pageSize + " startFrom " + startFrom ); + String base, String filter, String attrs[], + String startFrom, String sortKey, + int pageSize) throws EBaseException { + + CMS.debug("In DBVirtualList filter attrs startFrom sortKey pageSize " + + "filter: " + filter + + " attrs: " + Arrays.toString(attrs) + + " pageSize " + pageSize + " startFrom " + startFrom); mRegistry = registry; mFilter = filter; try { mConn = (LDAPConnection) c.clone(); } catch (Exception e) { - throw new EBaseException(CMS.getUserMessage("CMS_BASE_CONN_FAILED", + throw new EBaseException(CMS.getUserMessage("CMS_BASE_CONN_FAILED", e.toString())); } mBase = base; @@ -260,7 +258,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { if (pageSize < 0) { mJumpToDirection = -1; - } + } mPageSize = pageSize; mBeforeCount = 0; @@ -291,7 +289,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { /** * set the sort key - * + * * @param sortKey the attribute to sort by */ public void setSortKey(String sortKey) throws EBaseException { @@ -303,7 +301,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { /** * set the sort key - * + * * @param sortKey the attributes to sort by */ public void setSortKey(String[] sortKeys) throws EBaseException { @@ -326,20 +324,20 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { * @message DBVirtualList: <exception thrown> */ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, - CMS.getLogMessage("OPERATION_ERROR", e.toString())); + CMS.getLogMessage("OPERATION_ERROR", e.toString())); } // Paged results also require a sort control if (mKeys != null) { mPageControls[0] = new LDAPSortControl(mKeys, true); - }else { + } else { throw new EBaseException("sort keys cannot be null"); } } /** * Retrieves the size of this virtual list. - * Recommend to call getSize() before getElementAt() or getElements() + * Recommend to call getSize() before getElementAt() or getElements() * since you'd better check if the index is out of bound first. */ public int getSize() { @@ -368,7 +366,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { if (mPageSize < 0) { mBeforeCount = mPageSize * -1; - mAfterCount = 0; + mAfterCount = 0; } cont = new LDAPVirtualListControl(mJumpTo, mBeforeCount, @@ -382,21 +380,21 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { return mSize; } - public int getSizeBeforeJumpTo() { + public int getSizeBeforeJumpTo() { if (!mInitialized || mJumpTo == null) return 0; int size = 0; - - if (mJumpToDirection < 0) { + + if (mJumpToDirection < 0) { size = mTop + mEntries.size(); } else { size = mTop; } - return size; + return size; } @@ -410,7 +408,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { return size; } - + private synchronized boolean getEntries() { // Specify necessary controls for vlist // LDAPSearchConstraints cons = mConn.getSearchConstraints(); @@ -461,7 +459,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { try { //maintain mEntries as vector of LDAPEntry @SuppressWarnings("unchecked") - E o = (E)mRegistry.createObject(entry.getAttributeSet()); + E o = (E) mRegistry.createObject(entry.getAttributeSet()); mEntries.addElement(o); } catch (Exception e) { @@ -475,12 +473,12 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { * @message DBVirtualList: <exception thrown> */ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, - CMS.getLogMessage("CMSCORE_DBS_VL_ADD", e.toString())); + CMS.getLogMessage("CMSCORE_DBS_VL_ADD", e.toString())); // #539044 damageCounter++; if (damageCounter > 100) { mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, - CMS.getLogMessage("CMSCORE_DBS_VL_CORRUPTED_ENTRIES", Integer.toString(damageCounter))); + CMS.getLogMessage("CMSCORE_DBS_VL_CORRUPTED_ENTRIES", Integer.toString(damageCounter))); return false; } } @@ -496,7 +494,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { CMS.debug("getEntries: exception " + e); mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, - CMS.getLogMessage("OPERATION_ERROR", e.toString())); + CMS.getLogMessage("OPERATION_ERROR", e.toString())); } //System.out.println( "Returning " + mEntries.size() + // " entries" ); @@ -515,10 +513,10 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { if (!getEntries()) return false; - // Check if we have a control returned + // Check if we have a control returned LDAPControl[] c = mConn.getResponseControls(); LDAPVirtualListResponse nextCont = - LDAPVirtualListResponse.parseResponse(c); + LDAPVirtualListResponse.parseResponse(c); if (nextCont != null) { mSelectedIndex = nextCont.getFirstPosition() - 1; @@ -536,7 +534,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { //System.out.println( "Virtual window: " + mTop + // ".." + (mTop+mEntries.size()-1) + // " of " + mSize ); - } else { + } else { mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_DBS_VL_NULL_RESPONSE")); } return true; @@ -546,14 +544,15 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { } } - /** Get a page starting at "first" (although we may also fetch + /** + * Get a page starting at "first" (although we may also fetch * some preceding entries) - * Recommend to call getSize() before getElementAt() or getElements() + * Recommend to call getSize() before getElementAt() or getElements() * since you'd better check if the index is out of bound first. - * + * * @param first the index of the first entry of the page you want to fetch */ - public boolean getPage(int first) { + public boolean getPage(int first) { CMS.debug("getPage " + first); if (!mInitialized) { LDAPVirtualListControl cont = new LDAPVirtualListControl(0, @@ -568,17 +567,18 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { return getPage(); } - /** Fetch a buffer + /** + * Fetch a buffer */ - private boolean getPage() { + private boolean getPage() { // Get the actual entries if (!getEntries()) return false; - // Check if we have a control returned + // Check if we have a control returned LDAPControl[] c = mConn.getResponseControls(); LDAPVirtualListResponse nextCont = - LDAPVirtualListResponse.parseResponse(c); + LDAPVirtualListResponse.parseResponse(c); if (nextCont != null) { mSelectedIndex = nextCont.getFirstPosition() - 1; @@ -598,38 +598,39 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { * @phase local ldap search */ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, - CMS.getLogMessage("CMSCORE_DBS_VL_NULL_RESPONSE")); + CMS.getLogMessage("CMSCORE_DBS_VL_NULL_RESPONSE")); } return true; } - /** Called by application to scroll the list with initial letters. + /** + * Called by application to scroll the list with initial letters. * Consider text to be an initial substring of the attribute of the * primary sorting key(the first one specified in the sort key array) * of an entry. * If no entries match, the one just before(or after, if none before) * will be returned as mSelectedIndex - * + * * @param text the prefix of the first entry of the page you want to fetch */ public boolean getPage(String text) { mPageControls[1] = new LDAPVirtualListControl(text, - mBeforeCount, - mAfterCount); + mBeforeCount, + mAfterCount); //System.out.println( "Setting requested start to " + // text + ", -" + mBeforeCount + ", +" + // mAfterCount ); return getPage(); } - /** + /** * fetch data of a single list item - * Recommend to call getSize() before getElementAt() or getElements() + * Recommend to call getSize() before getElementAt() or getElements() * since you'd better check if the index is out of bound first. * If the index is out of range of the virtual list, an exception will be thrown * and return null - * + * * @param index the index of the element to fetch */ public E getElementAt(int index) { @@ -643,36 +644,36 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { if (!mInitialized) mSize = getSize(); - CMS.debug("getElementAt: " + index + " mTop " + mTop); - + CMS.debug("getElementAt: " + index + " mTop " + mTop); + //System.out.println( "need entry " + index ); if ((index < 0) || (index >= mSize)) { CMS.debug("returning null"); return null; } - if (mJumpTo != null) { //Handle the explicit jumpto case + if (mJumpTo != null) { //Handle the explicit jumpto case if (index == 0) - mJumpToIndex = 0; // Keep a running jumpto index for this page of data + mJumpToIndex = 0; // Keep a running jumpto index for this page of data else mJumpToIndex++; - - //CMS.debug("getElementAtJT: " + index + " mTop " + mTop + " mEntries.size() " + mEntries.size()); - - if ((mJumpToDirection > 0) && (mJumpToInitialIndex + index >= mSize)) // out of data in forward paging jumpto case + + //CMS.debug("getElementAtJT: " + index + " mTop " + mTop + " mEntries.size() " + mEntries.size()); + + if ((mJumpToDirection > 0) && (mJumpToInitialIndex + index >= mSize)) // out of data in forward paging jumpto case { CMS.debug("mJumpTo virtual list exhausted mTop " + mTop + " mSize " + mSize); return null; } - - if (mJumpToIndex >= mEntries.size()) // In jumpto case, page of data has been exhausted + + if (mJumpToIndex >= mEntries.size()) // In jumpto case, page of data has been exhausted { - mJumpToIndex = 0; // new page will be needed reset running count + mJumpToIndex = 0; // new page will be needed reset running count - if (mJumpToDirection > 0) { //proceed in positive direction past hit point - getPage(index + mJumpToInitialIndex + 1); - } else { //proceed backwards from hit point + if (mJumpToDirection > 0) { //proceed in positive direction past hit point + getPage(index + mJumpToInitialIndex + 1); + } else { //proceed backwards from hit point if (mTop == 0) { getPage(0); CMS.debug("asking for a page less than zero in reverse case, return null"); @@ -681,15 +682,15 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { CMS.debug("getting page reverse mJumptoIndex " + mJumpToIndex + " mTop " + mTop); getPage(mTop); - + } } - if (mJumpToDirection > 0) // handle getting entry in forward direction + if (mJumpToDirection > 0) // handle getting entry in forward direction { return mEntries.elementAt(mJumpToIndex); - } else { // handle getting entry in reverse direction + } else { // handle getting entry in reverse direction int reverse_index = mEntries.size() - mJumpToIndex - 1; CMS.debug("reverse direction getting index " + reverse_index); @@ -704,7 +705,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { //CMS.debug("getElementAt noJumpto: " + index); - if ((index < mTop) || (index >= mTop + mEntries.size())) { // handle the non jumpto case + if ((index < mTop) || (index >= mTop + mEntries.size())) { // handle the non jumpto case //fetch a new page //System.out.println( "fetching a page starting at " + // index ); @@ -727,10 +728,10 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { /** * This function processes elements as soon as it arrives. It is - * more memory-efficient. + * more memory-efficient. */ public void processElements(int startidx, int endidx, IElementProcessor ep) - throws EBaseException { + throws EBaseException { /* mSize may not be init at this time! Bad ! * the caller should really check the index is within bound before this @@ -739,7 +740,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { if (!mInitialized) mSize = getSize(); - // short-cut the existing code ... :( + // short-cut the existing code ... :( if (mJumpTo != null) { for (int i = startidx; i <= endidx; i++) { Object element = getJumpToElementAt(i); @@ -753,7 +754,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { //guess this is what you really mean to try to improve performance if (startidx >= endidx) { throw new EBaseException("startidx must be less than endidx"); - }else { + } else { setPageSize(endidx - startidx); getPage(startidx); } @@ -766,14 +767,14 @@ public class DBVirtualList<E> implements IDBVirtualList<E> { } } - /** + /** * get the virutal selected index */ public int getSelectedIndex() { return mSelectedIndex; } - /** + /** * get the top of the buffer */ public int getFirstIndex() { diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/DateArrayMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/DateArrayMapper.java index b8df1240c..a2dfc9c01 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/DateArrayMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/DateArrayMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Date; import java.util.Enumeration; import java.util.Vector; @@ -29,14 +28,13 @@ import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; - /** * A class represents ann attribute mapper that maps * a Java Date array object into LDAP attribute, * and vice versa. - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class DateArrayMapper implements IDBAttrMapper { @@ -61,9 +59,9 @@ public class DateArrayMapper implements IDBAttrMapper { /** * Maps object to a set of attributes. */ - public void mapObjectToLDAPAttributeSet(IDBObj parent, - String name, Object obj, LDAPAttributeSet attrs) - throws EBaseException { + public void mapObjectToLDAPAttributeSet(IDBObj parent, + String name, Object obj, LDAPAttributeSet attrs) + throws EBaseException { Date dates[] = (Date[]) obj; if (dates == null) @@ -80,8 +78,8 @@ public class DateArrayMapper implements IDBAttrMapper { * Maps LDAP attributes into object, and put the object * into 'parent'. */ - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { LDAPAttribute attr = attrs.getAttribute(mLdapName); if (attr == null) @@ -104,8 +102,8 @@ public class DateArrayMapper implements IDBAttrMapper { /** * Maps search filters into LDAP search filter. */ - public String mapSearchFilter(String name, String op, - String value) throws EBaseException { + public String mapSearchFilter(String name, String op, + String value) throws EBaseException { return mLdapName + op + value; } } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/DateMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/DateMapper.java index d547a4459..58cd1bfee 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/DateMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/DateMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; @@ -31,12 +30,11 @@ import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; - /** * A class represents ann attribute mapper that maps * a Java Date object into LDAP attribute, * and vice versa. - * + * * @author thomask * @version $Revision$, $Date$ */ @@ -45,7 +43,7 @@ public class DateMapper implements IDBAttrMapper { private String mLdapName = null; private Vector v = new Vector(); private static SimpleDateFormat formatter = new - SimpleDateFormat("yyyyMMddHHmmss'Z'"); + SimpleDateFormat("yyyyMMddHHmmss'Z'"); /** * Constructs date mapper. @@ -66,9 +64,9 @@ public class DateMapper implements IDBAttrMapper { * Maps object to ldap attribute set. */ public void mapObjectToLDAPAttributeSet(IDBObj parent, - String name, Object obj, LDAPAttributeSet attrs) - throws EBaseException { - attrs.add(new LDAPAttribute(mLdapName, + String name, Object obj, LDAPAttributeSet attrs) + throws EBaseException { + attrs.add(new LDAPAttribute(mLdapName, dateToDB((Date) obj))); } @@ -77,7 +75,7 @@ public class DateMapper implements IDBAttrMapper { * into 'parent'. */ public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + String name, IDBObj parent) throws EBaseException { LDAPAttribute attr = attrs.getAttribute(mLdapName); if (attr == null) @@ -90,7 +88,7 @@ public class DateMapper implements IDBAttrMapper { * Maps search filters into LDAP search filter. */ public String mapSearchFilter(String name, String op, - String value) throws EBaseException { + String value) throws EBaseException { String val = null; try { diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/IntegerMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/IntegerMapper.java index c5601a9bf..8d9384927 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/IntegerMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/IntegerMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Enumeration; import java.util.Vector; @@ -28,14 +27,13 @@ import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; - /** * A class represents ann attribute mapper that maps * a Java Integer object into LDAP attribute, * and vice versa. - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class IntegerMapper implements IDBAttrMapper { @@ -60,10 +58,10 @@ public class IntegerMapper implements IDBAttrMapper { /** * Maps object to ldap attribute set. */ - public void mapObjectToLDAPAttributeSet(IDBObj parent, - String name, Object obj, LDAPAttributeSet attrs) - throws EBaseException { - attrs.add(new LDAPAttribute(mLdapName, + public void mapObjectToLDAPAttributeSet(IDBObj parent, + String name, Object obj, LDAPAttributeSet attrs) + throws EBaseException { + attrs.add(new LDAPAttribute(mLdapName, ((Integer) obj).toString())); } @@ -71,8 +69,8 @@ public class IntegerMapper implements IDBAttrMapper { * Maps LDAP attributes into object, and put the object * into 'parent'. */ - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { LDAPAttribute attr = attrs.getAttribute(mLdapName); if (attr == null) @@ -84,8 +82,8 @@ public class IntegerMapper implements IDBAttrMapper { /** * Maps search filters into LDAP search filter. */ - public String mapSearchFilter(String name, String op, - String value) throws EBaseException { + public String mapSearchFilter(String name, String op, + String value) throws EBaseException { return mLdapName + op + value; } } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/KeyDBSchema.java b/pki/base/common/src/com/netscape/cmscore/dbs/KeyDBSchema.java index ff7764247..ca9db779b 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/KeyDBSchema.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/KeyDBSchema.java @@ -17,14 +17,11 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - - - /** - * A class represents a collection of key record + * A class represents a collection of key record * specific schema information. * <P> - * + * * @author thomask * @version $Revision$, $Date$ */ @@ -43,9 +40,9 @@ public class KeyDBSchema { public static final String LDAP_ATTR_KEY_SIZE = "keySize"; public static final String LDAP_ATTR_ALGORITHM = "algorithm"; public static final String LDAP_ATTR_STATE = "keyState"; - public static final String LDAP_ATTR_DATE_OF_RECOVERY = - "dateOfRecovery"; - public static final String LDAP_ATTR_PUBLIC_KEY_FORMAT = - "publicKeyFormat"; + public static final String LDAP_ATTR_DATE_OF_RECOVERY = + "dateOfRecovery"; + public static final String LDAP_ATTR_PUBLIC_KEY_FORMAT = + "publicKeyFormat"; public static final String LDAP_ATTR_ARCHIVED_BY = "archivedBy"; } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecord.java b/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecord.java index 2c1265f78..f42377fe2 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecord.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecord.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.math.BigInteger; import java.util.Date; import java.util.Enumeration; @@ -29,14 +28,13 @@ import com.netscape.certsrv.dbs.IDBObj; import com.netscape.certsrv.dbs.keydb.IKeyRecord; import com.netscape.certsrv.dbs.keydb.KeyState; - /** * A class represents a Key record. It maintains the key * life cycle as well as other information about an * archived key. Namely, whether a key is inactive because * of compromise. * <P> - * + * * @author thomask * @version $Revision$, $Date$ */ @@ -86,10 +84,10 @@ public class KeyRecord implements IDBObj, IKeyRecord { * * @param key key to be archived */ - public KeyRecord(BigInteger serialNo, byte publicData[], - byte privateData[], String owner, - String algorithm, String agentId) - throws EBaseException { + public KeyRecord(BigInteger serialNo, byte publicData[], + byte privateData[], String owner, + String algorithm, String agentId) + throws EBaseException { mSerialNo = serialNo; mPublicKey = publicData; mPrivateKey = privateData; @@ -196,7 +194,7 @@ public class KeyRecord implements IDBObj, IKeyRecord { * Retrieves serial number of the key record. Each key record * is uniquely identified by serial number. * <P> - * + * * @return serial number of this key record */ public BigInteger getSerialNumber() throws EBaseException { @@ -211,10 +209,10 @@ public class KeyRecord implements IDBObj, IKeyRecord { } /** - * Retrieves the key state. This gives key life cycle + * Retrieves the key state. This gives key life cycle * information. * <P> - * + * * @return key state */ public KeyState getState() throws EBaseException { @@ -239,7 +237,7 @@ public class KeyRecord implements IDBObj, IKeyRecord { /** * Retrieves key. * <P> - * + * * @return archived key */ public byte[] getPrivateKeyData() throws EBaseException { @@ -256,7 +254,7 @@ public class KeyRecord implements IDBObj, IKeyRecord { /** * Retrieves the key size. * <P> - * + * * @return key size */ public Integer getKeySize() throws EBaseException { @@ -280,7 +278,7 @@ public class KeyRecord implements IDBObj, IKeyRecord { } /** - * Sets owner name. + * Sets owner name. * <P> */ public void setOwnerName(String name) throws EBaseException { @@ -338,7 +336,7 @@ public class KeyRecord implements IDBObj, IKeyRecord { } /** - * Retrieves the last modification time of + * Retrieves the last modification time of * this record. */ public Date getModifyTime() { 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 f4882ffc4..dd0c88a97 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecordList.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecordList.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Enumeration; import java.util.Vector; @@ -26,11 +25,10 @@ import com.netscape.certsrv.dbs.IDBVirtualList; import com.netscape.certsrv.dbs.keydb.IKeyRecord; import com.netscape.certsrv.dbs.keydb.IKeyRecordList; - /** * A class represents a list of key records. * <P> - * + * * @author thomask * @version $Revision$, $Date$ */ @@ -46,13 +44,13 @@ public class KeyRecordList implements IKeyRecordList { } /** - * Retrieves the size of key list. + * Retrieves the size of key list. */ public int getSize() { return mVlist.getSize(); } - public int getSizeBeforeJumpTo() { + public int getSizeBeforeJumpTo() { return mVlist.getSizeBeforeJumpTo(); @@ -66,15 +64,17 @@ public class KeyRecordList implements IKeyRecordList { public IKeyRecord getKeyRecord(int i) { KeyRecord record = (KeyRecord) mVlist.getElementAt(i); - if (record == null) return null; + if (record == null) + return null; + + return record; + } - return record; - } /** * Retrieves requests. */ public Enumeration getKeyRecords(int startidx, int endidx) - throws EBaseException { + throws EBaseException { Vector entries = new Vector(); for (int i = startidx; i <= endidx; i++) { diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecordMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecordMapper.java index 1cbd3229d..550cd15e7 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecordMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/KeyRecordMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.math.BigInteger; import java.util.Enumeration; import java.util.Vector; @@ -33,14 +32,13 @@ import com.netscape.certsrv.dbs.IDBObj; import com.netscape.certsrv.dbs.keydb.IKeyRecord; import com.netscape.certsrv.dbs.keydb.IKeyRepository; import com.netscape.certsrv.logging.ILogger; - /** - * A class represents a mapper to serialize + * A class represents a mapper to serialize * key record into database. * <P> - * - * @author thomask + * + * @author thomask * @version $Revision$, $Date$ */ public class KeyRecordMapper implements IDBAttrMapper { @@ -59,8 +57,8 @@ public class KeyRecordMapper implements IDBAttrMapper { return v.elements(); } - public void mapObjectToLDAPAttributeSet(IDBObj parent, String name, - Object obj, LDAPAttributeSet attrs) throws EBaseException { + public void mapObjectToLDAPAttributeSet(IDBObj parent, String name, + Object obj, LDAPAttributeSet attrs) throws EBaseException { try { KeyRecord rec = (KeyRecord) obj; @@ -73,23 +71,23 @@ public class KeyRecordMapper implements IDBAttrMapper { * @phase Maps object to ldap attribute set * @message KeyRecordMapper: <exception thrown> */ - mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, - CMS.getLogMessage("CMSCORE_DBS_KEYRECORD_MAPPER_ERROR", e.toString())); + mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, + CMS.getLogMessage("CMSCORE_DBS_KEYRECORD_MAPPER_ERROR", e.toString())); throw new EDBException( CMS.getUserMessage("CMS_DBS_SERIALIZE_FAILED", name)); } } - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { - try { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { + try { LDAPAttribute attr = attrs.getAttribute( KeyDBSchema.LDAP_ATTR_KEY_RECORD_ID); if (attr == null) return; String serialno = (String) attr.getStringValues().nextElement(); - IKeyRecord rec = mDB.readKeyRecord(new + IKeyRecord rec = mDB.readKeyRecord(new BigInteger(serialno)); parent.set(name, rec); @@ -100,15 +98,15 @@ public class KeyRecordMapper implements IDBAttrMapper { * @phase Maps ldap attribute set to object * @message KeyRecordMapper: <exception thrown> */ - mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, - CMS.getLogMessage("CMSCORE_DBS_KEYRECORD_MAPPER_ERROR", e.toString())); + mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, + CMS.getLogMessage("CMSCORE_DBS_KEYRECORD_MAPPER_ERROR", e.toString())); throw new EDBException( CMS.getUserMessage("CMS_DBS_DESERIALIZE_FAILED", name)); } } public String mapSearchFilter(String name, String op, String value) - throws EBaseException { + throws EBaseException { return name + op + value; } } 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 f684718cf..fc2d2c10a 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.math.BigInteger; import java.security.PublicKey; import java.util.Date; @@ -39,12 +38,11 @@ import com.netscape.certsrv.dbs.keydb.IKeyRecordList; import com.netscape.certsrv.dbs.keydb.IKeyRepository; import com.netscape.certsrv.dbs.repository.IRepository; - /** * A class represents a Key repository. This is the container of * archived keys. * <P> - * + * * @author thomask * @version $Revision$, $Date$ */ @@ -62,12 +60,12 @@ public class KeyRepository extends Repository implements IKeyRepository { * Constructs a key repository. It checks if the key repository * does exist. If not, it creates the repository. * <P> - * + * * @param service db service * @exception EBaseException failed to setup key repository */ public KeyRepository(IDBSubsystem service, int increment, String baseDN) - throws EDBException { + throws EDBException { super(service, increment, baseDN); mBaseDN = baseDN; mDBService = service; @@ -81,55 +79,55 @@ public class KeyRepository extends Repository implements IKeyRepository { if (!reg.isObjectClassRegistered(KeyRecord.class.getName())) { reg.registerObjectClass(KeyRecord.class.getName(), - keyRecordOC); + keyRecordOC); } if (!reg.isAttributeRegistered(KeyRecord.ATTR_ID)) { reg.registerAttribute(KeyRecord.ATTR_ID, new - BigIntegerMapper(KeyDBSchema.LDAP_ATTR_SERIALNO)); + BigIntegerMapper(KeyDBSchema.LDAP_ATTR_SERIALNO)); } if (!reg.isAttributeRegistered(KeyRecord.ATTR_ALGORITHM)) { reg.registerAttribute(KeyRecord.ATTR_ALGORITHM, new - StringMapper(KeyDBSchema.LDAP_ATTR_ALGORITHM)); + StringMapper(KeyDBSchema.LDAP_ATTR_ALGORITHM)); } if (!reg.isAttributeRegistered(KeyRecord.ATTR_STATE)) { reg.registerAttribute(KeyRecord.ATTR_STATE, new - KeyStateMapper(KeyDBSchema.LDAP_ATTR_STATE)); + KeyStateMapper(KeyDBSchema.LDAP_ATTR_STATE)); } if (!reg.isAttributeRegistered(KeyRecord.ATTR_KEY_SIZE)) { reg.registerAttribute(KeyRecord.ATTR_KEY_SIZE, new - IntegerMapper(KeyDBSchema.LDAP_ATTR_KEY_SIZE)); + IntegerMapper(KeyDBSchema.LDAP_ATTR_KEY_SIZE)); } if (!reg.isAttributeRegistered(KeyRecord.ATTR_OWNER_NAME)) { reg.registerAttribute(KeyRecord.ATTR_OWNER_NAME, new - StringMapper(KeyDBSchema.LDAP_ATTR_OWNER_NAME)); + StringMapper(KeyDBSchema.LDAP_ATTR_OWNER_NAME)); } if (!reg.isAttributeRegistered(KeyRecord.ATTR_PRIVATE_KEY_DATA)) { reg.registerAttribute(KeyRecord.ATTR_PRIVATE_KEY_DATA, new - ByteArrayMapper(KeyDBSchema.LDAP_ATTR_PRIVATE_KEY_DATA)); + ByteArrayMapper(KeyDBSchema.LDAP_ATTR_PRIVATE_KEY_DATA)); } if (!reg.isAttributeRegistered(KeyRecord.ATTR_PUBLIC_KEY_DATA)) { reg.registerAttribute(KeyRecord.ATTR_PUBLIC_KEY_DATA, new - PublicKeyMapper(KeyDBSchema.LDAP_ATTR_PUBLIC_KEY_DATA)); + PublicKeyMapper(KeyDBSchema.LDAP_ATTR_PUBLIC_KEY_DATA)); } if (!reg.isAttributeRegistered(KeyRecord.ATTR_DATE_OF_RECOVERY)) { reg.registerAttribute(KeyRecord.ATTR_DATE_OF_RECOVERY, new - DateArrayMapper(KeyDBSchema.LDAP_ATTR_DATE_OF_RECOVERY)); + DateArrayMapper(KeyDBSchema.LDAP_ATTR_DATE_OF_RECOVERY)); } if (!reg.isAttributeRegistered(KeyRecord.ATTR_CREATE_TIME)) { reg.registerAttribute(KeyRecord.ATTR_CREATE_TIME, new - DateMapper(KeyDBSchema.LDAP_ATTR_CREATE_TIME)); + DateMapper(KeyDBSchema.LDAP_ATTR_CREATE_TIME)); } if (!reg.isAttributeRegistered(KeyRecord.ATTR_MODIFY_TIME)) { reg.registerAttribute(KeyRecord.ATTR_MODIFY_TIME, new - DateMapper(KeyDBSchema.LDAP_ATTR_MODIFY_TIME)); + DateMapper(KeyDBSchema.LDAP_ATTR_MODIFY_TIME)); } if (!reg.isAttributeRegistered(KeyRecord.ATTR_META_INFO)) { reg.registerAttribute(KeyRecord.ATTR_META_INFO, new - MetaInfoMapper(KeyDBSchema.LDAP_ATTR_META_INFO)); + MetaInfoMapper(KeyDBSchema.LDAP_ATTR_META_INFO)); } if (!reg.isAttributeRegistered(KeyRecord.ATTR_ARCHIVED_BY)) { reg.registerAttribute(KeyRecord.ATTR_ARCHIVED_BY, new - StringMapper(KeyDBSchema.LDAP_ATTR_ARCHIVED_BY)); + StringMapper(KeyDBSchema.LDAP_ATTR_ARCHIVED_BY)); } } @@ -147,7 +145,7 @@ public class KeyRepository extends Repository implements IKeyRepository { CMS.debug("In setKeyStatusUpdateInterval mKeyStatusUpdateThread " + mKeyStatusUpdateThread); if (mKeyStatusUpdateThread == null) { CMS.debug("In setKeyStatusUpdateInterval about to create KeyStatusUpdateThread "); - mKeyStatusUpdateThread = new KeyStatusUpdateThread(this, requestRepo, "KeyStatusUpdateThread"); + mKeyStatusUpdateThread = new KeyStatusUpdateThread(this, requestRepo, "KeyStatusUpdateThread"); mKeyStatusUpdateThread.setInterval(interval); mKeyStatusUpdateThread.start(); } else { @@ -171,15 +169,14 @@ public class KeyRepository extends Repository implements IKeyRepository { /** * Removes all objects with this repository. */ - public void removeAllObjects() throws EBaseException - { + public void removeAllObjects() throws EBaseException { String filter = "(" + KeyRecord.ATTR_OWNER_NAME + "=*" + ")"; IKeyRecordList list = findKeyRecordsInList(filter, null, "serialno", 10); int size = list.getSize(); Enumeration<IKeyRecord> e = list.getKeyRecords(0, size - 1); while (e.hasMoreElements()) { - IKeyRecord rec = e.nextElement(); + IKeyRecord rec = e.nextElement(); deleteKeyRecord(rec.getSerialNumber()); } } @@ -187,7 +184,7 @@ public class KeyRepository extends Repository implements IKeyRepository { /** * Archives a key to the repository. * <P> - * + * * @param record key record * @exception EBaseException failed to archive key */ @@ -196,34 +193,38 @@ public class KeyRepository extends Repository implements IKeyRepository { try { String name = "cn" + "=" + - ((KeyRecord) record).getSerialNumber().toString() + "," + getDN(); + ((KeyRecord) record).getSerialNumber().toString() + "," + getDN(); - if (s != null) s.add(name, (KeyRecord) record); - } finally { - if (s != null) s.close(); + if (s != null) + s.add(name, (KeyRecord) record); + } finally { + if (s != null) + s.close(); } } /** * Recovers an archived key by serial number. * <P> - * + * * @param serialNo serial number * @return key record * @exception EBaseException failed to recover key */ public IKeyRecord readKeyRecord(BigInteger serialNo) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); KeyRecord rec = null; try { String name = "cn" + "=" + - serialNo.toString() + "," + getDN(); + serialNo.toString() + "," + getDN(); - if (s != null) rec = (KeyRecord) s.read(name); - } finally { - if (s != null) s.close(); + if (s != null) + rec = (KeyRecord) s.read(name); + } finally { + if (s != null) + s.close(); } return rec; } @@ -231,26 +232,27 @@ public class KeyRepository extends Repository implements IKeyRepository { /** * Recovers an archived key by owner name. * <P> - * + * * @param ownerName owner name * @return key record * @exception EBaseException failed to recover key */ public IKeyRecord readKeyRecord(X500Name ownerName) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); KeyRecord keyRec = null; try { if (ownerName != null) { String filter = "(" + KeyRecord.ATTR_OWNER_NAME + "=" + - ownerName.toString() + ")"; + ownerName.toString() + ")"; IDBSearchResults res = s.search(getDN(), filter); keyRec = (KeyRecord) res.nextElement(); - } - } finally { - if (s != null) s.close(); + } + } finally { + if (s != null) + s.close(); } return keyRec; } @@ -259,7 +261,7 @@ public class KeyRepository extends Repository implements IKeyRepository { * Recovers archived key using public key. */ public IKeyRecord readKeyRecord(PublicKey publicKey) - throws EBaseException { + throws EBaseException { // XXX - setup binary search attributes byte data[] = publicKey.getEncoded(); @@ -270,39 +272,40 @@ public class KeyRepository extends Repository implements IKeyRepository { try { String filter = "(" + KeyRecord.ATTR_PUBLIC_KEY_DATA + "=" + - escapeBinaryData(data) + ")"; - if( s != null ) { + escapeBinaryData(data) + ")"; + if (s != null) { IDBSearchResults res = s.search(getDN(), filter); rec = (KeyRecord) res.nextElement(); } - } finally { - if (s != null) s.close(); + } finally { + if (s != null) + s.close(); } return rec; } - /** * Recovers archived key using b64 encoded cert */ public IKeyRecord readKeyRecord(String cert) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); KeyRecord rec = null; try { - String filter = "(publicKey=x509cert#\"" +cert+"\")"; -CMS.debug("filter= " + filter); + String filter = "(publicKey=x509cert#\"" + cert + "\")"; + CMS.debug("filter= " + filter); - if( s != null ) { + if (s != null) { IDBSearchResults res = s.search(getDN(), filter); rec = (KeyRecord) res.nextElement(); } - } finally { - if (s != null) s.close(); + } finally { + if (s != null) + s.close(); } return rec; } @@ -311,32 +314,36 @@ CMS.debug("filter= " + filter); * Modifies key record. */ public void modifyKeyRecord(BigInteger serialNo, ModificationSet mods) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); try { String name = "cn" + "=" + - serialNo.toString() + "," + getDN(); + serialNo.toString() + "," + getDN(); mods.add(KeyRecord.ATTR_MODIFY_TIME, Modification.MOD_REPLACE, - new Date()); - if (s != null) s.modify(name, mods); - } finally { - if (s != null) s.close(); + new Date()); + if (s != null) + s.modify(name, mods); + } finally { + if (s != null) + s.close(); } } public void deleteKeyRecord(BigInteger serialNo) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); try { String name = "cn" + "=" + - serialNo.toString() + "," + getDN(); + serialNo.toString() + "," + getDN(); - if (s != null) s.delete(name); - } finally { - if (s != null) s.close(); + if (s != null) + s.delete(name); + } finally { + if (s != null) + s.close(); } } @@ -353,7 +360,7 @@ CMS.debug("filter= " + filter); } public Enumeration<Object> searchKeys(String filter, int maxSize) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration<Object> e = null; @@ -367,7 +374,7 @@ CMS.debug("filter= " + filter); } public Enumeration<Object> searchKeys(String filter, int maxSize, int timeLimit) - throws EBaseException { + throws EBaseException { IDBSSession s = mDBService.createSession(); Enumeration<Object> e = null; @@ -384,14 +391,14 @@ CMS.debug("filter= " + filter); * Retrieves key record list. */ public IKeyRecordList findKeyRecordsInList(String filter, - String attrs[], int pageSize) throws EBaseException { + String attrs[], int pageSize) throws EBaseException { return findKeyRecordsInList(filter, attrs, IKeyRecord.ATTR_ID, - pageSize); + pageSize); } public IKeyRecordList findKeyRecordsInList(String filter, - String attrs[], String sortKey, int pageSize) - throws EBaseException { + String attrs[], String sortKey, int pageSize) + throws EBaseException { IDBSSession s = mDBService.createSession(); IKeyRecordList list = null; @@ -399,18 +406,19 @@ CMS.debug("filter= " + filter); if (s != null) { list = new KeyRecordList( s.createVirtualList(getDN(), "(&(objectclass=" + - KeyRecord.class.getName() + ")" + filter + ")", - attrs, sortKey, pageSize)); + KeyRecord.class.getName() + ")" + filter + ")", + attrs, sortKey, pageSize)); } - } finally { - if (s != null) s.close(); + } finally { + if (s != null) + s.close(); } return list; } public IKeyRecordList findKeyRecordsInList(String filter, - String attrs[],String jumpTo, String sortKey, int pageSize) - throws EBaseException { + String attrs[], String jumpTo, String sortKey, int pageSize) + throws EBaseException { IDBSSession s = mDBService.createSession(); IKeyRecordList list = null; @@ -419,86 +427,85 @@ CMS.debug("filter= " + filter); String jumpToVal = null; if (len > 9) { - jumpToVal = Integer.toString(len) + jumpTo; - } else { - jumpToVal = "0" + Integer.toString(len) + jumpTo; + jumpToVal = Integer.toString(len) + jumpTo; + } else { + jumpToVal = "0" + Integer.toString(len) + jumpTo; } try { if (s != null) { list = new KeyRecordList( s.createVirtualList(getDN(), "(&(objectclass=" + - KeyRecord.class.getName() + ")" + filter + ")", - attrs,jumpToVal, sortKey, pageSize)); + KeyRecord.class.getName() + ")" + filter + ")", + attrs, jumpToVal, sortKey, pageSize)); } } finally { - if (s != null) s.close(); + if (s != null) + s.close(); } return list; } - public BigInteger getLastSerialNumberInRange(BigInteger serial_low_bound, BigInteger serial_upper_bound) throws - EBaseException { + public BigInteger getLastSerialNumberInRange(BigInteger serial_low_bound, BigInteger serial_upper_bound) throws + EBaseException { - CMS.debug("KeyRepository: in getLastSerialNumberInRange: low " + serial_low_bound + " high " + serial_upper_bound); + CMS.debug("KeyRepository: in getLastSerialNumberInRange: low " + serial_low_bound + " high " + serial_upper_bound); - if(serial_low_bound == null || serial_upper_bound == null || serial_low_bound.compareTo(serial_upper_bound) >= 0) - { - return null; - } + if (serial_low_bound == null || serial_upper_bound == null || serial_low_bound.compareTo(serial_upper_bound) >= 0) { + return null; + } - String ldapfilter = "(" + "serialno" + "=*" + ")"; - String[] attrs = null; + String ldapfilter = "(" + "serialno" + "=*" + ")"; + String[] attrs = null; - KeyRecordList recList = (KeyRecordList) findKeyRecordsInList(ldapfilter,attrs,serial_upper_bound.toString(10),"serialno", 5 * -1); + KeyRecordList recList = (KeyRecordList) findKeyRecordsInList(ldapfilter, attrs, serial_upper_bound.toString(10), "serialno", 5 * -1); - int size = recList.getSize(); + int size = recList.getSize(); - CMS.debug("KeyRepository: getLastSerialNumberInRange: recList size " + size); + CMS.debug("KeyRepository: getLastSerialNumberInRange: recList size " + size); - if (size <= 0) { - CMS.debug("KeyRepository: getLastSerialNumberInRange: index may be empty"); + if (size <= 0) { + CMS.debug("KeyRepository: getLastSerialNumberInRange: index may be empty"); - BigInteger ret = new BigInteger(serial_low_bound.toString(10)); + BigInteger ret = new BigInteger(serial_low_bound.toString(10)); - ret = ret.add(new BigInteger("-1")); + ret = ret.add(new BigInteger("-1")); - CMS.debug("KeyRepository: getLastSerialNumberInRange returning: " + ret ); - return ret; - } - int ltSize = recList.getSizeBeforeJumpTo(); + CMS.debug("KeyRepository: getLastSerialNumberInRange returning: " + ret); + return ret; + } + int ltSize = recList.getSizeBeforeJumpTo(); - CMS.debug("KeyRepository:getLastSerialNumberInRange: ltSize " + ltSize); + CMS.debug("KeyRepository:getLastSerialNumberInRange: ltSize " + ltSize); - int i; - KeyRecord curRec = null; + int i; + KeyRecord curRec = null; - for (i = 0; i < 5; i++) { - curRec = (KeyRecord) recList.getKeyRecord(i); + for (i = 0; i < 5; i++) { + curRec = (KeyRecord) recList.getKeyRecord(i); - if (curRec != null) { + if (curRec != null) { - BigInteger serial = curRec.getSerialNumber(); + BigInteger serial = curRec.getSerialNumber(); - CMS.debug("KeyRepository: getLastCertRecordSerialNo: serialno " + serial); + CMS.debug("KeyRepository: getLastCertRecordSerialNo: serialno " + serial); - if( ((serial.compareTo(serial_low_bound) == 0) || (serial.compareTo(serial_low_bound) == 1) ) && - ((serial.compareTo(serial_upper_bound) == 0) || (serial.compareTo(serial_upper_bound) == -1) )) - { - CMS.debug("KeyRepository: getLastSerialNumberInRange returning: " + serial); - return serial; - } - } else { - CMS.debug("KeyRepository: getLastSerialNumberInRange:found null from getCertRecord"); - } - } + if (((serial.compareTo(serial_low_bound) == 0) || (serial.compareTo(serial_low_bound) == 1)) && + ((serial.compareTo(serial_upper_bound) == 0) || (serial.compareTo(serial_upper_bound) == -1))) { + CMS.debug("KeyRepository: getLastSerialNumberInRange returning: " + serial); + return serial; + } + } else { + CMS.debug("KeyRepository: getLastSerialNumberInRange:found null from getCertRecord"); + } + } - BigInteger ret = new BigInteger(serial_low_bound.toString(10)); + BigInteger ret = new BigInteger(serial_low_bound.toString(10)); - ret = ret.add(new BigInteger("-1")); + ret = ret.add(new BigInteger("-1")); - CMS.debug("KeyRepository: getLastSerialNumberInRange returning: " + ret ); - return ret ; + CMS.debug("KeyRepository: getLastSerialNumberInRange returning: " + ret); + return ret; } @@ -538,7 +545,7 @@ class KeyStatusUpdateThread extends Thread { CMS.debug("Starting key checkRanges"); _kr.checkRanges(); CMS.debug("key checkRanges done"); - + CMS.debug("Starting request checkRanges"); _rr.checkRanges(); CMS.debug("request checkRanges done"); @@ -553,5 +560,3 @@ class KeyStatusUpdateThread extends Thread { } } } - - diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/KeyStateMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/KeyStateMapper.java index 7f13c8ed2..dc6aadff1 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/KeyStateMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/KeyStateMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Enumeration; import java.util.Vector; @@ -29,13 +28,12 @@ import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; import com.netscape.certsrv.dbs.keydb.KeyState; - /** * A class represents a key state mapper. * <P> - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class KeyStateMapper implements IDBAttrMapper { @@ -52,10 +50,10 @@ public class KeyStateMapper implements IDBAttrMapper { return v.elements(); } - public void mapObjectToLDAPAttributeSet(IDBObj parent, - String name, Object obj, LDAPAttributeSet attrs) - throws EBaseException { - attrs.add(new LDAPAttribute(mLdapName, + public void mapObjectToLDAPAttributeSet(IDBObj parent, + String name, Object obj, LDAPAttributeSet attrs) + throws EBaseException { + attrs.add(new LDAPAttribute(mLdapName, ((KeyState) obj).toString())); } @@ -63,8 +61,8 @@ public class KeyStateMapper implements IDBAttrMapper { * Maps LDAP attributes into object, and put the object * into 'parent'. */ - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { LDAPAttribute attr = attrs.getAttribute(mLdapName); if (attr == null) { @@ -77,8 +75,8 @@ public class KeyStateMapper implements IDBAttrMapper { /** * Maps search filters into LDAP search filter. */ - public String mapSearchFilter(String name, String op, - String value) throws EBaseException { + public String mapSearchFilter(String name, String op, + String value) throws EBaseException { return mLdapName + op + value; } } 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 909bf47e1..74ac7ca96 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/LdapFilterConverter.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/LdapFilterConverter.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Hashtable; import com.netscape.certsrv.base.AttributeNameHelper; @@ -25,14 +24,13 @@ import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IFilterConverter; - /** * A class represents a filter converter * that understands how to convert a attribute * type from one defintion to another. * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class LdapFilterConverter implements IFilterConverter { diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/LongMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/LongMapper.java index cdd9aeb77..2d2d539ed 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/LongMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/LongMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Enumeration; import java.util.Vector; @@ -28,14 +27,13 @@ import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; - /** * A class represents ann attribute mapper that maps * a Java Long object into LDAP attribute, * and vice versa. - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class LongMapper implements IDBAttrMapper { @@ -60,10 +58,10 @@ public class LongMapper implements IDBAttrMapper { /** * Maps object into ldap attribute set. */ - public void mapObjectToLDAPAttributeSet(IDBObj parent, - String name, Object obj, LDAPAttributeSet attrs) - throws EBaseException { - attrs.add(new LDAPAttribute(mLdapName, + public void mapObjectToLDAPAttributeSet(IDBObj parent, + String name, Object obj, LDAPAttributeSet attrs) + throws EBaseException { + attrs.add(new LDAPAttribute(mLdapName, LongToDB((Long) obj))); } @@ -71,8 +69,8 @@ public class LongMapper implements IDBAttrMapper { * Maps LDAP attributes into object, and put the object * into 'parent'. */ - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { LDAPAttribute attr = attrs.getAttribute(mLdapName); if (attr == null) @@ -84,8 +82,8 @@ public class LongMapper implements IDBAttrMapper { /** * Maps search filters into LDAP search filter. */ - public String mapSearchFilter(String name, String op, - String value) throws EBaseException { + public String mapSearchFilter(String name, String op, + String value) throws EBaseException { String v = null; try { diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/MetaInfoMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/MetaInfoMapper.java index 605e2fadf..f175c811a 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/MetaInfoMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/MetaInfoMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Enumeration; import java.util.StringTokenizer; import java.util.Vector; @@ -30,20 +29,19 @@ import com.netscape.certsrv.base.MetaInfo; import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; - /** * A class represent mapper for metainfo attribute. Metainfo * is in format of the following: - * + * * <PRE> * metaInfoType:metaInfoValue * metaInfoType:metaInfoValue * metaInfoType:metaInfoValue * metaInfoType:metaInfoValue * </PRE> - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class MetaInfoMapper implements IDBAttrMapper { @@ -71,8 +69,8 @@ public class MetaInfoMapper implements IDBAttrMapper { * Maps object into ldap attribute set. */ public void mapObjectToLDAPAttributeSet(IDBObj parent, - String name, Object obj, LDAPAttributeSet attrs) - throws EBaseException { + String name, Object obj, LDAPAttributeSet attrs) + throws EBaseException { MetaInfo info = (MetaInfo) obj; Enumeration e = info.getElements(); @@ -96,7 +94,7 @@ public class MetaInfoMapper implements IDBAttrMapper { * 'parent'. */ public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + String name, IDBObj parent) throws EBaseException { LDAPAttribute attr = attrs.getAttribute(mLdapName); if (attr == null) @@ -119,7 +117,7 @@ public class MetaInfoMapper implements IDBAttrMapper { * (&(metaInfo=reserver0:value0)(metaInfo=reserved1:value1)) */ public String mapSearchFilter(String name, String op, - String value) throws EBaseException { + String value) throws EBaseException { return mLdapName + op + value; } } 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 46979715b..f77a36ed4 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/ObjectStreamMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/ObjectStreamMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -35,15 +34,14 @@ import com.netscape.certsrv.dbs.EDBException; import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; import com.netscape.certsrv.logging.ILogger; - /** * A class represents ann attribute mapper that maps * a Java object into LDAP attribute, * and vice versa. - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class ObjectStreamMapper implements IDBAttrMapper { @@ -69,9 +67,9 @@ public class ObjectStreamMapper implements IDBAttrMapper { /** * Maps object to ldap attribute set. */ - public void mapObjectToLDAPAttributeSet(IDBObj parent, String name, - Object obj, LDAPAttributeSet attrs) - throws EBaseException { + public void mapObjectToLDAPAttributeSet(IDBObj parent, String name, + Object obj, LDAPAttributeSet attrs) + throws EBaseException { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); @@ -79,13 +77,13 @@ public class ObjectStreamMapper implements IDBAttrMapper { os.writeObject(obj); byte data[] = bos.toByteArray(); if (data == null) { - CMS.debug("ObjectStreamMapper:mapObjectToLDAPAttributeSet " + + CMS.debug("ObjectStreamMapper:mapObjectToLDAPAttributeSet " + name + " size=0"); } else { - CMS.debug("ObjectStreamMapper:mapObjectToLDAPAttributeSet " + + CMS.debug("ObjectStreamMapper:mapObjectToLDAPAttributeSet " + name + " size=" + data.length); } - attrs.add(new LDAPAttribute(mLdapName, + attrs.add(new LDAPAttribute(mLdapName, data)); } catch (IOException e) { @@ -94,9 +92,9 @@ public class ObjectStreamMapper implements IDBAttrMapper { * @phase Maps object to ldap attribute set * @message ObjectStreamMapper: <exception thrown> */ - mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, - CMS.getLogMessage("CMSCORE_DBS_OBJECTSTREAM_MAPPER_ERROR", - e.toString())); + mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, + CMS.getLogMessage("CMSCORE_DBS_OBJECTSTREAM_MAPPER_ERROR", + e.toString())); throw new EDBException( CMS.getUserMessage("CMS_DBS_SERIALIZE_FAILED", name)); } @@ -106,8 +104,8 @@ public class ObjectStreamMapper implements IDBAttrMapper { * Maps LDAP attributes into object, and put the object * into 'parent'. */ - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { try { LDAPAttribute attr = attrs.getAttribute(mLdapName); @@ -131,8 +129,8 @@ public class ObjectStreamMapper implements IDBAttrMapper { /** * Maps search filters into LDAP search filter. */ - public String mapSearchFilter(String name, String op, - String value) throws EBaseException { + public String mapSearchFilter(String name, String op, + String value) throws EBaseException { return mLdapName + op + value; } } 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 8a2d1f2d2..f4d8cabeb 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/PublicKeyMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/PublicKeyMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.security.PublicKey; import java.security.cert.X509Certificate; import java.util.Enumeration; @@ -32,16 +31,15 @@ import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; import com.netscape.certsrv.logging.ILogger; import com.netscape.cmscore.cert.CertUtils; - /** * A class represents an attribute mapper that maps * a public key data into LDAP attribute and * vice versa. * <P> - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class PublicKeyMapper implements IDBAttrMapper { @@ -68,9 +66,9 @@ public class PublicKeyMapper implements IDBAttrMapper { /** * Maps object to ldap attribute set. */ - public void mapObjectToLDAPAttributeSet(IDBObj parent, - String name, Object obj, LDAPAttributeSet attrs) - throws EBaseException { + public void mapObjectToLDAPAttributeSet(IDBObj parent, + String name, Object obj, LDAPAttributeSet attrs) + throws EBaseException { attrs.add(new LDAPAttribute(mLdapName, (byte[]) obj)); } @@ -78,8 +76,8 @@ public class PublicKeyMapper implements IDBAttrMapper { * Maps LDAP attributes into object, and put the object * into 'parent'. */ - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { LDAPAttribute attr = attrs.getAttribute(mLdapName); if (attr == null) { @@ -92,8 +90,8 @@ public class PublicKeyMapper implements IDBAttrMapper { * Maps search filters into LDAP search filter. It knows * how to extract public key from the certificate. */ - public String mapSearchFilter(String name, String op, - String value) throws EBaseException { + public String mapSearchFilter(String name, String op, + String value) throws EBaseException { int i = value.indexOf("#"); if (i != -1) { @@ -116,9 +114,9 @@ public class PublicKeyMapper implements IDBAttrMapper { * @phase Maps search filters into LDAP search filter * @message PublicKeyMapper: <exception thrown> */ - mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, - CMS.getLogMessage("CMSCORE_DBS_PUBLICKEY_MAPPER_ERROR", - e.toString())); + mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, + CMS.getLogMessage("CMSCORE_DBS_PUBLICKEY_MAPPER_ERROR", + e.toString())); } } return mLdapName + op + value; diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/ReplicaIDRepository.java b/pki/base/common/src/com/netscape/cmscore/dbs/ReplicaIDRepository.java index 61beb4236..c016e5acd 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/ReplicaIDRepository.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/ReplicaIDRepository.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.math.BigInteger; import com.netscape.certsrv.apps.CMS; @@ -30,12 +29,12 @@ import com.netscape.certsrv.dbs.replicadb.IReplicaIDRepository; * A class represents a replica repository. It * creates unique managed replica IDs. * <P> - * + * * @author alee * @version $Revision$, $Date$ */ public class ReplicaIDRepository extends Repository - implements IReplicaIDRepository { + implements IReplicaIDRepository { private IDBSubsystem mDBService; private String mBaseDN; @@ -44,24 +43,23 @@ public class ReplicaIDRepository extends Repository * Constructs a certificate repository. */ public ReplicaIDRepository(IDBSubsystem dbService, int increment, String baseDN) - throws EDBException { + throws EDBException { super(dbService, increment, baseDN); mBaseDN = baseDN; mDBService = dbService; } - - + /** * Returns last serial number in given range */ public BigInteger getLastSerialNumberInRange(BigInteger serial_low_bound, BigInteger serial_upper_bound) - throws EBaseException { - CMS.debug("ReplicaIDReposoitory: in getLastSerialNumberInRange: low " + serial_low_bound + " high " + serial_upper_bound); - if(serial_low_bound == null || serial_upper_bound == null || serial_low_bound.compareTo(serial_upper_bound) >= 0 ) { + throws EBaseException { + CMS.debug("ReplicaIDReposoitory: in getLastSerialNumberInRange: low " + serial_low_bound + " high " + serial_upper_bound); + if (serial_low_bound == null || serial_upper_bound == null || serial_low_bound.compareTo(serial_upper_bound) >= 0) { return null; } BigInteger ret = new BigInteger(getMinSerial()); - if ((ret==null) || (ret.compareTo(serial_upper_bound) >0) || (ret.compareTo(serial_low_bound) <0)) { + if ((ret == null) || (ret.compareTo(serial_upper_bound) > 0) || (ret.compareTo(serial_low_bound) < 0)) { return null; } return ret; diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/Repository.java b/pki/base/common/src/com/netscape/cmscore/dbs/Repository.java index 858e7a639..106a1c214 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/Repository.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/Repository.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.math.BigInteger; import com.netscape.certsrv.apps.CMS; @@ -36,18 +35,17 @@ import com.netscape.certsrv.dbs.repository.IRepository; import com.netscape.certsrv.dbs.repository.IRepositoryRecord; /** - * A class represents a generic repository. It maintains unique + * A class represents a generic repository. It maintains unique * serial number within repository. * <P> - * To build domain specific repository, subclass should be - * created. + * To build domain specific repository, subclass should be created. * <P> - * + * * @author galperin * @author thomask * @version $Revision: 1.4 - * - $, $Date$ + * + * $, $Date$ */ public abstract class Repository implements IRepository { @@ -56,7 +54,7 @@ public abstract class Repository implements IRepository { private BigInteger BI_INCREMENT = null; private static final BigInteger BI_ZERO = new BigInteger("0"); // (the next serialNo to be issued) - 1 - private BigInteger mSerialNo = null; + private BigInteger mSerialNo = null; // the serialNo attribute stored in db private BigInteger mNext = null; @@ -79,51 +77,49 @@ public abstract class Repository implements IRepository { private int mRadix = 10; private int mRepo = -1; - private BigInteger mLastSerialNo = null; + /** * Constructs a repository. * <P> */ - public Repository(IDBSubsystem db, int increment, String baseDN) - throws EDBException { + public Repository(IDBSubsystem db, int increment, String baseDN) + throws EDBException { mDB = db; mBaseDN = baseDN; - BI_INCREMENT = new BigInteger(Integer.toString(increment)); // register schema IDBRegistry reg = db.getRegistry(); /** - if (!reg.isObjectClassRegistered( - RepositoryRecord.class.getName())) { - String repRecordOC[] = new String[2]; - repRecordOC[0] = RepositorySchema.LDAP_OC_TOP; - repRecordOC[1] = RepositorySchema.LDAP_OC_REPOSITORY; - reg.registerObjectClass( - RepositoryRecord.class.getName(), repRecordOC); - } - if (!reg.isAttributeRegistered(RepositoryRecord.ATTR_SERIALNO)) { - reg.registerAttribute(RepositoryRecord.ATTR_SERIALNO, - new BigIntegerMapper(RepositorySchema.LDAP_ATTR_SERIALNO)); - } + * if (!reg.isObjectClassRegistered( + * RepositoryRecord.class.getName())) { + * String repRecordOC[] = new String[2]; + * repRecordOC[0] = RepositorySchema.LDAP_OC_TOP; + * repRecordOC[1] = RepositorySchema.LDAP_OC_REPOSITORY; + * reg.registerObjectClass( + * RepositoryRecord.class.getName(), repRecordOC); + * } + * if (!reg.isAttributeRegistered(RepositoryRecord.ATTR_SERIALNO)) { + * reg.registerAttribute(RepositoryRecord.ATTR_SERIALNO, + * new BigIntegerMapper(RepositorySchema.LDAP_ATTR_SERIALNO)); + * } **/ } /** * Resets serial number. */ - public void resetSerialNumber(BigInteger serial) throws EBaseException - { + public void resetSerialNumber(BigInteger serial) throws EBaseException { IDBSSession s = mDB.createSession(); - + try { String name = mBaseDN; ModificationSet mods = new ModificationSet(); mods.add(IRepositoryRecord.ATTR_SERIALNO, - Modification.MOD_REPLACE, serial); + Modification.MOD_REPLACE, serial); s.modify(name, mods); } finally { if (s != null) @@ -134,7 +130,7 @@ public abstract class Repository implements IRepository { /** * Retrieves the next serial number attr in db. * <P> - * + * * @return next serial number */ protected BigInteger getSerialNumber() throws EBaseException { @@ -144,15 +140,17 @@ public abstract class Repository implements IRepository { RepositoryRecord rec = null; try { - if (s != null) rec = (RepositoryRecord) s.read(mBaseDN); - } finally { - if (s != null) s.close(); + if (s != null) + rec = (RepositoryRecord) s.read(mBaseDN); + } finally { + if (s != null) + s.close(); } - if( rec == null ) { - CMS.debug( "Repository::getSerialNumber() - " - + "- rec is null!" ); - throw new EBaseException( "rec is null" ); + if (rec == null) { + CMS.debug("Repository::getSerialNumber() - " + + "- rec is null!"); + throw new EBaseException("rec is null"); } BigInteger serial = rec.getSerialNumber(); @@ -168,7 +166,7 @@ public abstract class Repository implements IRepository { serial = serial.add(BI_ONE); setSerialNumber(serial); } - }catch (EBaseException e) { + } catch (EBaseException e) { // do nothing } mInit = true; @@ -179,12 +177,12 @@ public abstract class Repository implements IRepository { /** * Updates the serial number to the specified in db. * <P> - * + * * @param num serial number */ protected void setSerialNumber(BigInteger num) throws EBaseException { - CMS.debug("Repository:setSerialNumber " + num.toString()); + CMS.debug("Repository:setSerialNumber " + num.toString()); return; @@ -211,8 +209,8 @@ public abstract class Repository implements IRepository { maxSerial = new BigInteger(serial, mRadix); if (maxSerial != null) { - mMaxSerial = serial; - mMaxSerialNo = maxSerial; + mMaxSerial = serial; + mMaxSerialNo = maxSerial; } } @@ -237,23 +235,22 @@ public abstract class Repository implements IRepository { maxSerial = new BigInteger(serial, mRadix); if (maxSerial != null) { - mNextMaxSerial = serial; - mNextMaxSerialNo = maxSerial; + mNextMaxSerial = serial; + mNextMaxSerialNo = maxSerial; } return; } - + /** * Get the minimum serial number. * * @return minimum serial number */ public String getMinSerial() { - return mMinSerial; + return mMinSerial; } - /** * init serial number cache */ @@ -261,14 +258,14 @@ public abstract class Repository implements IRepository { mNext = getSerialNumber(); BigInteger serialConfig = new BigInteger("0"); mRadix = 10; - + CMS.debug("Repository: in InitCache"); if (this instanceof ICertificateRepository) { CMS.debug("Repository: Instance of Certificate Repository."); mRadix = 16; mRepo = IDBSubsystem.CERTS; - } else if (this instanceof IKeyRepository) { + } else if (this instanceof IKeyRepository) { // Key Repository uses the same configuration parameters as Certificate // Repository. This is ok because they are on separate subsystems. CMS.debug("Repository: Instance of Key Repository"); @@ -292,48 +289,47 @@ public abstract class Repository implements IRepository { CMS.debug("Repository: minSerial " + mMinSerial + " maxSerial: " + mMaxSerial); - if(mMinSerial != null) - mMinSerialNo = new BigInteger(mMinSerial,mRadix); + if (mMinSerial != null) + mMinSerialNo = new BigInteger(mMinSerial, mRadix); - if(mMaxSerial != null) - mMaxSerialNo = new BigInteger(mMaxSerial,mRadix); + if (mMaxSerial != null) + mMaxSerialNo = new BigInteger(mMaxSerial, mRadix); - if(mNextMinSerial != null) - mNextMinSerialNo = new BigInteger(mNextMinSerial,mRadix); + if (mNextMinSerial != null) + mNextMinSerialNo = new BigInteger(mNextMinSerial, mRadix); - if(mNextMaxSerial != null) - mNextMaxSerialNo = new BigInteger(mNextMaxSerial,mRadix); + if (mNextMaxSerial != null) + mNextMaxSerialNo = new BigInteger(mNextMaxSerial, mRadix); - if(lowWaterMark != null) - mLowWaterMarkNo = new BigInteger(lowWaterMark,mRadix); + if (lowWaterMark != null) + mLowWaterMarkNo = new BigInteger(lowWaterMark, mRadix); - if(increment != null) - mIncrementNo = new BigInteger(increment,mRadix); + if (increment != null) + mIncrementNo = new BigInteger(increment, mRadix); BigInteger theSerialNo = null; - theSerialNo = getLastSerialNumberInRange(mMinSerialNo,mMaxSerialNo); + theSerialNo = getLastSerialNumberInRange(mMinSerialNo, mMaxSerialNo); - if(theSerialNo != null) { + if (theSerialNo != null) { mLastSerialNo = new BigInteger(theSerialNo.toString()); CMS.debug("Repository: mLastSerialNo: " + mLastSerialNo.toString()); - } - else { + } else { throw new EBaseException("Error in obtaining the last serial number in the repository!"); } } - + /** * get the next serial number in cache */ public BigInteger getTheSerialNumber() throws EBaseException { - - CMS.debug("Repository:In getTheSerialNumber " ); - if (mLastSerialNo == null) + + CMS.debug("Repository:In getTheSerialNumber "); + if (mLastSerialNo == null) initCache(); BigInteger serial = new BigInteger((mLastSerialNo.add(BI_ONE)).toString()); @@ -346,7 +342,7 @@ public abstract class Repository implements IRepository { /** * Updates the serial number to the specified in db and cache. * <P> - * + * * @param num serial number */ public void setTheSerialNumber(BigInteger num) throws EBaseException { @@ -373,43 +369,42 @@ public abstract class Repository implements IRepository { * Retrieves the next serial number, and also increase the * serial number by one. * <P> - * + * * @return serial number */ public synchronized BigInteger getNextSerialNumber() throws EBaseException { CMS.debug("Repository: in getNextSerialNumber. "); - + if (mLastSerialNo == null) { initCache(); mLastSerialNo = mLastSerialNo.add(BI_ONE); - - + } else { mLastSerialNo = mLastSerialNo.add(BI_ONE); } - if( mLastSerialNo == null ) { - CMS.debug( "Repository::getNextSerialNumber() " + - "- mLastSerialNo is null!" ); - throw new EBaseException( "mLastSerialNo is null" ); + if (mLastSerialNo == null) { + CMS.debug("Repository::getNextSerialNumber() " + + "- mLastSerialNo is null!"); + throw new EBaseException("mLastSerialNo is null"); } // check if we have reached the end of the range // if so, move to next range - if (mLastSerialNo.compareTo( mMaxSerialNo ) > 0 ) { + if (mLastSerialNo.compareTo(mMaxSerialNo) > 0) { if (mDB.getEnableSerialMgmt()) { CMS.debug("Reached the end of the range. Attempting to move to next range"); mMinSerialNo = mNextMinSerialNo; mMaxSerialNo = mNextMaxSerialNo; mLastSerialNo = mMinSerialNo; - mNextMinSerialNo = null; - mNextMaxSerialNo = null; + mNextMinSerialNo = null; + mNextMaxSerialNo = null; if ((mMaxSerialNo == null) || (mMinSerialNo == null)) { throw new EDBException(CMS.getUserMessage("CMS_DBS_LIMIT_REACHED", - mLastSerialNo.toString())); + mLastSerialNo.toString())); } // persist the changes @@ -426,17 +421,16 @@ public abstract class Repository implements IRepository { BigInteger retSerial = new BigInteger(mLastSerialNo.toString()); CMS.debug("Repository: getNextSerialNumber: returning retSerial " + retSerial); - return retSerial; + return retSerial; } /** - * Checks to see if a new range is needed, or if we have reached the end of the + * Checks to see if a new range is needed, or if we have reached the end of the * current range, or if a range conflict has occurred. - * + * * @exception EBaseException failed to check next range for conflicts */ - public void checkRanges() throws EBaseException - { + public void checkRanges() throws EBaseException { if (!mDB.getEnableSerialMgmt()) { CMS.debug("Serial Management not enabled. Returning .. "); return; @@ -464,7 +458,7 @@ public abstract class Repository implements IRepository { CMS.debug("Serial Numbers available: " + numsAvail.toString()); } - if ((numsAvail.compareTo(mLowWaterMarkNo) < 0) && (!CMS.isPreOpMode()) ) { + if ((numsAvail.compareTo(mLowWaterMarkNo) < 0) && (!CMS.isPreOpMode())) { CMS.debug("Low water mark reached. Requesting next range"); mNextMinSerialNo = new BigInteger(mDB.getNextRange(mRepo), mRadix); if (mNextMinSerialNo == null) { @@ -478,31 +472,30 @@ public abstract class Repository implements IRepository { } } - if (numsInRange.compareTo (mLowWaterMarkNo) < 0 ) { + if (numsInRange.compareTo(mLowWaterMarkNo) < 0) { // check for a replication error CMS.debug("Checking for a range conflict"); if (mDB.hasRangeConflict(mRepo)) { - CMS.debug("Range Conflict found! Removing next range."); - mNextMaxSerialNo = null; - mNextMinSerialNo= null; - mDB.setNextMinSerialConfig(mRepo, null); - mDB.setNextMaxSerialConfig(mRepo, null); + CMS.debug("Range Conflict found! Removing next range."); + mNextMaxSerialNo = null; + mNextMinSerialNo = null; + mDB.setNextMinSerialConfig(mRepo, null); + mDB.setNextMaxSerialConfig(mRepo, null); } - } + } } /** * Sets whether serial number management is enabled for certs - * and requests. - * - * @param value true/false - * @exception EBaseException failed to set + * and requests. + * + * @param value true/false + * @exception EBaseException failed to set */ - public void setEnableSerialMgmt(boolean value) throws EBaseException - { + public void setEnableSerialMgmt(boolean value) throws EBaseException { mDB.setEnableSerialMgmt(value); - } + } - public abstract BigInteger getLastSerialNumberInRange(BigInteger serial_low_bound, BigInteger serial_upper_bound) throws - EBaseException; + public abstract BigInteger getLastSerialNumberInRange(BigInteger serial_low_bound, BigInteger serial_upper_bound) throws + EBaseException; } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/RepositoryRecord.java b/pki/base/common/src/com/netscape/cmscore/dbs/RepositoryRecord.java index 97cedac8a..0a79b4b90 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/RepositoryRecord.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/RepositoryRecord.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.math.BigInteger; import java.util.Enumeration; import java.util.Vector; @@ -26,11 +25,10 @@ import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.repository.IRepositoryRecord; - /** * A class represents a repository record. * <P> - * + * * @author thomask * @version $Revision$, $Date$ */ diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/RepositorySchema.java b/pki/base/common/src/com/netscape/cmscore/dbs/RepositorySchema.java index 67cc5c1cd..4a0cf4155 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/RepositorySchema.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/RepositorySchema.java @@ -17,14 +17,11 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - - - /** * A class represents a collection of repository-specific * schema information. * <P> - * + * * @author thomask * @version $Revision$, $Date$ */ diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/RevocationInfo.java b/pki/base/common/src/com/netscape/cmscore/dbs/RevocationInfo.java index 001089fb0..00ca0034b 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/RevocationInfo.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/RevocationInfo.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.io.Serializable; import java.util.Date; @@ -26,13 +25,12 @@ import netscape.security.x509.CRLReasonExtension; import com.netscape.certsrv.dbs.certdb.IRevocationInfo; - /** * A class represents a certificate revocation info. This - * object is written as an attribute of certificate record + * object is written as an attribute of certificate record * which essentially signifies a revocation act. * <P> - * + * * @author galperin * @version $Revision$, $Date$ */ @@ -52,11 +50,11 @@ public class RevocationInfo implements IRevocationInfo, Serializable { } /** - * Constructs revocation info used by revocation + * Constructs revocation info used by revocation * request implementation. - * - * @param reason if not null contains CRL entry extension - * that specifies revocation reason + * + * @param reason if not null contains CRL entry extension + * that specifies revocation reason * @see CRLReasonExtension */ public RevocationInfo(Date revocationDate, CRLExtensions exts) { diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/RevocationInfoMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/RevocationInfoMapper.java index fc0eb3866..06ea075e8 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/RevocationInfoMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/RevocationInfoMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Date; import java.util.Enumeration; import java.util.Vector; @@ -37,13 +36,12 @@ import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; import com.netscape.cmscore.util.Debug; - /** - * A class represents a mapper to serialize + * A class represents a mapper to serialize * revocation information into database. * <P> - * - * @author thomask + * + * @author thomask * @version $Revision$, $Date$ */ public class RevocationInfoMapper implements IDBAttrMapper { @@ -63,9 +61,9 @@ public class RevocationInfoMapper implements IDBAttrMapper { return mNames.elements(); } - public void mapObjectToLDAPAttributeSet(IDBObj parent, String name, - Object obj, LDAPAttributeSet attrs) - throws EBaseException { + public void mapObjectToLDAPAttributeSet(IDBObj parent, String name, + Object obj, LDAPAttributeSet attrs) + throws EBaseException { try { // in format of <date>;<extensions> String value = ""; @@ -82,22 +80,22 @@ public class RevocationInfoMapper implements IDBAttrMapper { Extension ext = (Extension) e.nextElement(); if (ext instanceof CRLReasonExtension) { - RevocationReason reason = - ((CRLReasonExtension) ext).getReason(); + RevocationReason reason = + ((CRLReasonExtension) ext).getReason(); - value = value + ";CRLReasonExtension=" + + value = value + ";CRLReasonExtension=" + Integer.toString(reason.toInt()); } else if (ext instanceof InvalidityDateExtension) { - Date invalidityDate = - ((InvalidityDateExtension) ext).getInvalidityDate(); + Date invalidityDate = + ((InvalidityDateExtension) ext).getInvalidityDate(); - value = value + ";InvalidityDateExtension=" + + value = value + ";InvalidityDateExtension=" + DateMapper.dateToDB(invalidityDate); } else { Debug.trace("XXX skipped extension"); } } - attrs.add(new LDAPAttribute(CertDBSchema.LDAP_ATTR_REVO_INFO, + attrs.add(new LDAPAttribute(CertDBSchema.LDAP_ATTR_REVO_INFO, value)); } catch (Exception e) { Debug.trace(e.toString()); @@ -106,8 +104,8 @@ public class RevocationInfoMapper implements IDBAttrMapper { } } - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { try { LDAPAttribute attr = attrs.getAttribute( CertDBSchema.LDAP_ATTR_REVO_INFO); @@ -148,15 +146,14 @@ public class RevocationInfoMapper implements IDBAttrMapper { String invalidityDateStr = str.substring(24); Date invalidityDate = DateMapper.dateFromDB(invalidityDateStr); InvalidityDateExtension ext = - new InvalidityDateExtension(invalidityDate); + new InvalidityDateExtension(invalidityDate); exts.set(InvalidityDateExtension.NAME, ext); } else { Debug.trace("XXX skipped extension"); } - } - while (i != -1); - } + } while (i != -1); + } RevocationInfo info = new RevocationInfo(d, exts); parent.set(name, info); @@ -168,7 +165,7 @@ public class RevocationInfoMapper implements IDBAttrMapper { } public String mapSearchFilter(String name, String op, String value) - throws EBaseException { + throws EBaseException { return CertDBSchema.LDAP_ATTR_REVO_INFO + op + value; } } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/StringMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/StringMapper.java index 39fdac87e..5edc72669 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/StringMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/StringMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Enumeration; import java.util.NoSuchElementException; import java.util.Vector; @@ -29,14 +28,13 @@ import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; - /** * A class represents ann attribute mapper that maps * a Java String object into LDAP attribute, * and vice versa. - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class StringMapper implements IDBAttrMapper { @@ -61,9 +59,9 @@ public class StringMapper implements IDBAttrMapper { /** * Maps attribute value to ldap attributes. */ - public void mapObjectToLDAPAttributeSet(IDBObj parent, - String name, Object obj, LDAPAttributeSet attrs) - throws EBaseException { + public void mapObjectToLDAPAttributeSet(IDBObj parent, + String name, Object obj, LDAPAttributeSet attrs) + throws EBaseException { attrs.add(new LDAPAttribute(mLdapName, (String) obj)); } @@ -71,9 +69,9 @@ public class StringMapper implements IDBAttrMapper { * Maps LDAP attributes into object, and put the object * into 'parent'. */ - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) - throws EBaseException { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) + throws EBaseException { LDAPAttribute attr = attrs.getAttribute(mLdapName); if (attr == null) { @@ -81,7 +79,7 @@ public class StringMapper implements IDBAttrMapper { } try { parent.set(name, (String) - attr.getStringValues().nextElement()); + attr.getStringValues().nextElement()); } catch (NoSuchElementException e) { // attribute present, but without value } @@ -90,8 +88,8 @@ public class StringMapper implements IDBAttrMapper { /** * Maps search filters into LDAP search filter. */ - public String mapSearchFilter(String name, String op, - String value) throws EBaseException { + public String mapSearchFilter(String name, String op, + String value) throws EBaseException { return mLdapName + op + value; } } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/StringVectorMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/StringVectorMapper.java index d14470a2b..8fe1b74fa 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/StringVectorMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/StringVectorMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.util.Enumeration; import java.util.Vector; @@ -28,14 +27,13 @@ import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; - /** * A class represents ann attribute mapper that maps * a Java String object into LDAP attribute, * and vice versa. - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class StringVectorMapper implements IDBAttrMapper { @@ -60,9 +58,9 @@ public class StringVectorMapper implements IDBAttrMapper { /** * Maps attribute value to ldap attributes. */ - public void mapObjectToLDAPAttributeSet(IDBObj parent, - String name, Object obj, LDAPAttributeSet attrs) - throws EBaseException { + public void mapObjectToLDAPAttributeSet(IDBObj parent, + String name, Object obj, LDAPAttributeSet attrs) + throws EBaseException { Vector v = (Vector) obj; int s = v.size(); @@ -81,8 +79,8 @@ public class StringVectorMapper implements IDBAttrMapper { * Maps LDAP attributes into object, and put the object * into 'parent'. */ - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { LDAPAttribute attr = attrs.getAttribute(mLdapName); if (attr == null) @@ -104,8 +102,8 @@ public class StringVectorMapper implements IDBAttrMapper { /** * Maps search filters into LDAP search filter. */ - public String mapSearchFilter(String name, String op, - String value) throws EBaseException { + public String mapSearchFilter(String name, String op, + String value) throws EBaseException { return mLdapName + op + value; } } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/X500NameMapper.java b/pki/base/common/src/com/netscape/cmscore/dbs/X500NameMapper.java index 963c2fdc9..9d4da6e0f 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/X500NameMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/X500NameMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.io.IOException; import java.util.Enumeration; import java.util.Vector; @@ -32,15 +31,14 @@ import com.netscape.certsrv.dbs.EDBException; import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; import com.netscape.certsrv.logging.ILogger; - /** * A class represents ann attribute mapper that maps * a Java X500Name object into LDAP attribute, * and vice versa. - * + * * @author thomask - * @version $Revision$, $Date$ + * @version $Revision$, $Date$ */ public class X500NameMapper implements IDBAttrMapper { @@ -67,10 +65,10 @@ public class X500NameMapper implements IDBAttrMapper { /** * Maps attribute value to ldap attributes. */ - public void mapObjectToLDAPAttributeSet(IDBObj parent, - String name, Object obj, LDAPAttributeSet attrs) - throws EBaseException { - attrs.add(new LDAPAttribute(mLdapName, + public void mapObjectToLDAPAttributeSet(IDBObj parent, + String name, Object obj, LDAPAttributeSet attrs) + throws EBaseException { + attrs.add(new LDAPAttribute(mLdapName, ((X500Name) obj).toString())); } @@ -78,8 +76,8 @@ public class X500NameMapper implements IDBAttrMapper { * Maps LDAP attributes into object, and put the object * into 'parent'. */ - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { LDAPAttribute attr = attrs.getAttribute(mLdapName); if (attr == null) { @@ -95,9 +93,9 @@ public class X500NameMapper implements IDBAttrMapper { * @phase Maps LDAP attributes into object * @message X500NameMapper: <exception thrown> */ - mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, - CMS.getLogMessage("CMSCORE_DBS_X500NAME_MAPPER_ERROR", - e.toString())); + mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, + CMS.getLogMessage("CMSCORE_DBS_X500NAME_MAPPER_ERROR", + e.toString())); throw new EDBException( CMS.getUserMessage("CMS_DBS_DESERIALIZE_FAILED", name)); } @@ -106,8 +104,8 @@ public class X500NameMapper implements IDBAttrMapper { /** * Maps search filters into LDAP search filter. */ - public String mapSearchFilter(String name, String op, - String value) throws EBaseException { + public String mapSearchFilter(String name, String op, + String value) throws EBaseException { return mLdapName + op + value; } } 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 e1aa144b9..ddbc2cd07 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/X509CertImplMapper.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/X509CertImplMapper.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.dbs; - import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateException; import java.util.Date; @@ -43,12 +42,11 @@ import com.netscape.certsrv.dbs.IDBAttrMapper; import com.netscape.certsrv.dbs.IDBObj; import com.netscape.certsrv.dbs.certdb.ICertRecord; - /** - * A class represents a mapper to serialize + * A class represents a mapper to serialize * x509 certificate into database. - * - * @author thomask + * + * @author thomask * @version $Revision$, $Date$ */ public class X509CertImplMapper implements IDBAttrMapper { @@ -72,23 +70,23 @@ public class X509CertImplMapper implements IDBAttrMapper { return v.elements(); } - public void mapObjectToLDAPAttributeSet(IDBObj parent, String name, - Object obj, LDAPAttributeSet attrs) throws EBaseException { + public void mapObjectToLDAPAttributeSet(IDBObj parent, String name, + Object obj, LDAPAttributeSet attrs) throws EBaseException { try { X509CertImpl cert = (X509CertImpl) obj; // make information searchable Date notBefore = cert.getNotBefore(); attrs.add(new LDAPAttribute( - CertDBSchema.LDAP_ATTR_NOT_BEFORE, + CertDBSchema.LDAP_ATTR_NOT_BEFORE, DateMapper.dateToDB(notBefore))); Date notAfter = cert.getNotAfter(); - attrs.add(new LDAPAttribute(CertDBSchema.LDAP_ATTR_NOT_AFTER, + attrs.add(new LDAPAttribute(CertDBSchema.LDAP_ATTR_NOT_AFTER, DateMapper.dateToDB(notAfter))); - attrs.add(new LDAPAttribute(CertDBSchema.LDAP_ATTR_DURATION, + attrs.add(new LDAPAttribute(CertDBSchema.LDAP_ATTR_DURATION, DBSUtil.longToDB(notAfter.getTime() - notBefore.getTime()))); - attrs.add(new LDAPAttribute(CertDBSchema.LDAP_ATTR_SUBJECT, + attrs.add(new LDAPAttribute(CertDBSchema.LDAP_ATTR_SUBJECT, cert.getSubjectDN().getName())); attrs.add(new LDAPAttribute(CertDBSchema.LDAP_ATTR_PUBLIC_KEY_DATA, cert.getPublicKey().getEncoded())); // make extension searchable @@ -145,19 +143,19 @@ public class X509CertImplMapper implements IDBAttrMapper { // not know how to display the certificate in // pretty print format. attrs.add(new LDAPAttribute( - CertDBSchema.LDAP_ATTR_SIGNED_CERT + ";binary", + CertDBSchema.LDAP_ATTR_SIGNED_CERT + ";binary", cert.getEncoded())); attrs.add(new LDAPAttribute( - CertDBSchema.LDAP_ATTR_VERSION, + CertDBSchema.LDAP_ATTR_VERSION, Integer.toString(cert.getVersion()))); X509Key pubKey = (X509Key) cert.getPublicKey(); attrs.add(new LDAPAttribute( - CertDBSchema.LDAP_ATTR_ALGORITHM, + CertDBSchema.LDAP_ATTR_ALGORITHM, pubKey.getAlgorithmId().getOID().toString())); attrs.add(new LDAPAttribute( - CertDBSchema.LDAP_ATTR_SIGNING_ALGORITHM, + CertDBSchema.LDAP_ATTR_SIGNING_ALGORITHM, cert.getSigAlgOID())); } catch (CertificateEncodingException e) { throw new EDBException( @@ -203,7 +201,7 @@ public class X509CertImplMapper implements IDBAttrMapper { Boolean objectSigning = (Boolean) nsExt.get( NSCertTypeExtension.OBJECT_SIGNING); - result += "objectSigning=" + + result += "objectSigning=" + objectSigning.toString(); return result; } catch (Exception e) { @@ -240,8 +238,8 @@ public class X509CertImplMapper implements IDBAttrMapper { } } - public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, - String name, IDBObj parent) throws EBaseException { + public void mapLDAPAttributeSetToObject(LDAPAttributeSet attrs, + String name, IDBObj parent) throws EBaseException { try { // rebuild object quickly using binary image // XXX bad! when we add this attribute, @@ -263,7 +261,7 @@ public class X509CertImplMapper implements IDBAttrMapper { } if (attr != null) { byte der[] = (byte[]) - attr.getByteValues().nextElement(); + attr.getByteValues().nextElement(); X509CertImpl impl = new X509CertImpl(der); parent.set(name, impl); @@ -276,26 +274,26 @@ public class X509CertImplMapper implements IDBAttrMapper { //throw new EDBException( // DBResources.FAILED_TO_DESERIALIZE_1, name); parent.set(name, null); - + } } public String mapSearchFilter(String name, String op, String value) - throws EBaseException { + throws EBaseException { AttributeNameHelper h = new AttributeNameHelper(name); String suffix = h.getSuffix(); if (suffix.equalsIgnoreCase(ICertRecord.X509CERT_NOT_BEFORE)) { name = CertDBSchema.LDAP_ATTR_NOT_BEFORE; try { - value = DateMapper.dateToDB(new + value = DateMapper.dateToDB(new Date(Long.parseLong(value))); } catch (NumberFormatException e) { } } else if (suffix.equalsIgnoreCase(ICertRecord.X509CERT_NOT_AFTER)) { name = CertDBSchema.LDAP_ATTR_NOT_AFTER; try { - value = DateMapper.dateToDB(new + value = DateMapper.dateToDB(new Date(Long.parseLong(value))); } catch (NumberFormatException e) { } @@ -313,15 +311,15 @@ public class X509CertImplMapper implements IDBAttrMapper { } else if (suffix.equalsIgnoreCase(ICertRecord.X509CERT_SIGNING_ALGORITHM)) { name = CertDBSchema.LDAP_ATTR_SIGNING_ALGORITHM; } else if (suffix.equalsIgnoreCase(ICertRecord.X509CERT_SERIAL_NUMBER)) { - name = CertDBSchema.LDAP_ATTR_CERT_RECORD_ID; + name = CertDBSchema.LDAP_ATTR_CERT_RECORD_ID; } else if (suffix.equalsIgnoreCase(ICertRecord.X509CERT_EXTENSION)) { - name = CertDBSchema.LDAP_ATTR_EXTENSION; + name = CertDBSchema.LDAP_ATTR_EXTENSION; } else if (suffix.equalsIgnoreCase(ICertRecord.ATTR_REVO_INFO)) { - name = CertDBSchema.LDAP_ATTR_REVO_INFO; + name = CertDBSchema.LDAP_ATTR_REVO_INFO; value = "*;CRLReasonExtension=" + value + "*"; } else if (suffix.equalsIgnoreCase("nsExtension.SSLClient")) { // special case for NS cert type extension - name = CertDBSchema.LDAP_ATTR_EXTENSION; + name = CertDBSchema.LDAP_ATTR_EXTENSION; if (value.equals("on")) { value = "2.16.840.1.113730.1.1;*SSLClient=true*"; } else { @@ -329,7 +327,7 @@ public class X509CertImplMapper implements IDBAttrMapper { } } else if (suffix.equalsIgnoreCase("nsExtension.SSLServer")) { // special case for NS cert type extension - name = CertDBSchema.LDAP_ATTR_EXTENSION; + name = CertDBSchema.LDAP_ATTR_EXTENSION; if (value.equals("on")) { value = "2.16.840.1.113730.1.1;*SSLServer=true*"; } else { @@ -337,7 +335,7 @@ public class X509CertImplMapper implements IDBAttrMapper { } } else if (suffix.equalsIgnoreCase("nsExtension.SecureEmail")) { // special case for NS cert type extension - name = CertDBSchema.LDAP_ATTR_EXTENSION; + name = CertDBSchema.LDAP_ATTR_EXTENSION; if (value.equals("on")) { value = "2.16.840.1.113730.1.1;*Email=true*"; } else { @@ -345,7 +343,7 @@ public class X509CertImplMapper implements IDBAttrMapper { } } else if (suffix.equalsIgnoreCase("nsExtension.SubordinateSSLCA")) { // special case for NS cert type extension - name = CertDBSchema.LDAP_ATTR_EXTENSION; + name = CertDBSchema.LDAP_ATTR_EXTENSION; if (value.equals("on")) { value = "2.16.840.1.113730.1.1;*SSLCA=true*"; } else { @@ -353,7 +351,7 @@ public class X509CertImplMapper implements IDBAttrMapper { } } else if (suffix.equalsIgnoreCase("nsExtension.SubordinateEmailCA")) { // special case for NS cert type extension - name = CertDBSchema.LDAP_ATTR_EXTENSION; + name = CertDBSchema.LDAP_ATTR_EXTENSION; if (value.equals("on")) { value = "2.16.840.1.113730.1.1;*EmailCA=true*"; } else { @@ -361,7 +359,7 @@ public class X509CertImplMapper implements IDBAttrMapper { } } else if (suffix.equalsIgnoreCase("BasicConstraints.isCA")) { // special case for Basic Constraints extension - name = CertDBSchema.LDAP_ATTR_EXTENSION; + name = CertDBSchema.LDAP_ATTR_EXTENSION; if (value.equals("on")) { value = "2.5.29.19;*isCA=true*"; } else { |