summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cmscore/dbs
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cmscore/dbs')
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/BigIntegerMapper.java30
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/ByteArrayMapper.java32
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/CRLDBSchema.java8
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/CRLIssuingPointRecord.java22
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/CRLRepository.java225
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/CertDBSchema.java9
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/CertRecord.java20
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/CertRecordList.java35
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/CertRecordMapper.java23
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java758
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java162
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/DBSSession.java169
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/DBSUtil.java12
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/DBSearchResults.java28
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/DBSubsystem.java432
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java464
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/DateArrayMapper.java28
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/DateMapper.java24
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/IntegerMapper.java30
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/KeyDBSchema.java16
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/KeyRecord.java41
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/KeyRecordList.java18
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/KeyRecordMapper.java47
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java266
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/KeyStateMapper.java25
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/LdapFilterConverter.java9
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/LongMapper.java30
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/MetaInfoMapper.java26
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/ObjectStreamMapper.java46
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/PublicKeyMapper.java44
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/ReplicaIDRepository.java22
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/Repository.java217
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/RepositoryRecord.java4
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/RepositorySchema.java8
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/RevocationInfo.java19
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/RevocationInfoMapper.java43
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/StringMapper.java32
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/StringVectorMapper.java28
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/X500NameMapper.java42
-rw-r--r--pki/base/common/src/com/netscape/cmscore/dbs/X509CertImplMapper.java77
40 files changed, 1752 insertions, 1819 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 7cd563f9..4e8d0dcf 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,12 @@ 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.
- *
+ * 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,19 +58,18 @@ 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)));
}
/**
- * Maps LDAP attributes into object, and put the object
- * into 'parent'.
+ * 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 +81,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 b8e5b73d..f57eba26 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,12 @@ 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.
- *
+ * 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,26 +58,25 @@ 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));
}
/**
- * Maps LDAP attributes into object, and put the object
- * into 'parent'.
+ * 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 +87,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 58342a55..a47553fb 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,10 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.dbs;
-
-
-
/**
- * A class represents a collection of schema information
- * for CRL.
+ * 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 ea110d1c..239ba9b6 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;
@@ -78,8 +76,8 @@ public class CRLIssuingPointRecord implements ICRLIssuingPointRecord, IDBObj {
}
/**
- * Constructs empty CRLIssuingPointRecord. This is
- * required in database framework.
+ * Constructs empty CRLIssuingPointRecord. This is required in database
+ * framework.
*/
public CRLIssuingPointRecord() {
}
@@ -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 ba3ed5a7..3c70bf3d 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,9 @@ import com.netscape.certsrv.dbs.crldb.ICRLIssuingPointRecord;
import com.netscape.certsrv.dbs.crldb.ICRLRepository;
/**
- * A class represents a CRL repository. It stores all the
- * CRL issuing points.
+ * A class represents a CRL repository. It stores all the CRL issuing points.
* <P>
- *
+ *
* @author thomask
* @version $Revision$, $Date$
*/
@@ -52,8 +50,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 +59,21 @@ 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 +94,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 +121,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 +144,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 +166,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 +202,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 +227,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 +269,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 +286,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 +298,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 +325,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 83164aab..3718e504 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.
+ * 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 973ddc4f..e8d2c954 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,8 +81,7 @@ public class CertRecord implements IDBObj, ICertRecord {
}
/**
- * Constructs certiificate record with certificate
- * and meta info.
+ * Constructs certiificate record with certificate and meta info.
*/
public CertRecord(BigInteger id, Certificate cert, MetaInfo meta) {
mId = id;
@@ -205,14 +202,13 @@ public class CertRecord implements IDBObj, ICertRecord {
/**
* Retrieves revocation information.
*/
- public IRevocationInfo getRevocationInfo() {
- return mRevocationInfo;
+ public IRevocationInfo getRevocationInfo() {
+ return mRevocationInfo;
}
/**
- * Retrieves serial number of this record. Usually,
- * it is the same of the serial number of the
- * associated certificate.
+ * Retrieves serial number of this record. Usually, it is the same of the
+ * serial number of the associated certificate.
*/
public BigInteger getSerialNumber() {
return mId;
@@ -271,7 +267,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 3477360e..e1e3e5c0 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$
*/
@@ -69,35 +67,33 @@ 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.
+ * Process certificate record as soon as it is returned. kmccarth: changed
+ * to ignore startidx and endidx because VLVs don't 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++;
}
}
/**
- * Retrieves requests.
- * It's no good to call this if you didnt check
- * if the startidx, endidx are valid.
+ * Retrieves requests. It's no good to call this if you didnt check 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++) {
ICertRecord element = mVlist.getElementAt(i);
- // CMS.debug("gerCertRecords[" + i + "] element: " + element);
+ // CMS.debug("gerCertRecords[" + i + "] element: " + element);
if (element != null) {
entries.addElement(element);
}
@@ -106,11 +102,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 510da3c5..0c75e834 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,11 @@ 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
- * certificate record into database.
+ * 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 +55,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 +71,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 +92,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 bc3d279f..914da63a 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.
+ * 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);
}
}
@@ -223,9 +216,7 @@ public class CertificateRepository extends Repository
}
/**
- * interval value: (in seconds)
- * 0 - disable
- * >0 - enable
+ * interval value: (in seconds) 0 - disable >0 - enable
*/
public CertStatusUpdateThread mCertStatusUpdateThread = null;
public RetrieveModificationsThread mRetrieveModificationsThread = null;
@@ -243,8 +234,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 +264,6 @@ public class CertificateRepository extends Repository
}
}
-
/**
* Blocking method.
*/
@@ -281,21 +271,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 +295,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.
*/
@@ -320,22 +311,21 @@ public class CertificateRepository extends Repository
}
/**
- * Adds a certificate record to the repository. Each certificate
- * record contains four parts: certificate, meta-attributes,
- * issue information and reovcation information.
+ * Adds a certificate record to the repository. Each certificate 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
+ * @exception EBaseException failed to add new certificate to 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,15 +334,15 @@ 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);
}
- // Check validity of this certificate. If it is not invalid,
+ // Check validity of this certificate. If it is not invalid,
// mark it so. We will have a thread to transit the status
// from INVALID to VALID.
X509CertImpl x509cert = (X509CertImpl) record.get(
@@ -363,11 +353,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)
@@ -376,21 +366,20 @@ public class CertificateRepository extends Repository
}
/**
- * Used by the Clone Master (CLA) to add a revoked certificate
- * record to the 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
+ * @exception EBaseException failed to add new certificate to 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 {
@@ -400,8 +389,8 @@ public class CertificateRepository extends Repository
}
/**
- * This transits a certificate status from VALID to EXPIRED
- * if a certificate becomes expired.
+ * This transits a certificate status from VALID to EXPIRED if a certificate
+ * becomes expired.
*/
public void transitValidCertificates() throws EBaseException {
@@ -431,12 +420,13 @@ 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();
- //CMS.debug("notAfter " + notAfter.toString() + " now " + now.toString());
+ // CMS.debug("notAfter " + notAfter.toString() + " now " +
+ // now.toString());
if (notAfter.after(now)) {
CMS.debug("Record does not qualify,notAfter " + notAfter.toString() + " date " + now.toString());
continue;
@@ -461,13 +451,13 @@ public class CertificateRepository extends Repository
}
/**
- * This transits a certificate status from REVOKED to REVOKED_EXPIRED
- * if an revoked certificate becomes expired.
+ * This transits a certificate status from REVOKED to REVOKED_EXPIRED if an
+ * revoked certificate becomes expired.
*/
public void transitRevokedExpiredCertificates() throws EBaseException {
Date now = CMS.getCurrentDate();
ICertRecordList recList = getRevokedCertsByNotAfterDate(now, -1 * mTransitRecordPageSize);
-
+
int size = recList.getSize();
if (size <= 0) {
@@ -495,7 +485,8 @@ public class CertificateRepository extends Repository
Date notAfter = curRec.getNotAfter();
- // CMS.debug("notAfter " + notAfter.toString() + " now " + now.toString());
+ // CMS.debug("notAfter " + notAfter.toString() + " now " +
+ // now.toString());
if (notAfter.after(now)) {
CMS.debug("Record does not qualify,notAfter " + notAfter.toString() + " date " + now.toString());
continue;
@@ -506,7 +497,7 @@ public class CertificateRepository extends Repository
} else {
cList.add(curRec.getSerialNumber());
}
- } else {
+ } else {
CMS.debug("found null record in getCertRecord");
}
}
@@ -516,8 +507,8 @@ public class CertificateRepository extends Repository
}
/**
- * This transits a certificate status from INVALID to VALID
- * if a certificate becomes valid.
+ * This transits a certificate status from INVALID to VALID if a certificate
+ * becomes valid.
*/
public void transitInvalidCertificates() throws EBaseException {
@@ -554,7 +545,8 @@ public class CertificateRepository extends Repository
Date notBefore = curRec.getNotBefore();
- //CMS.debug("notBefore " + notBefore.toString() + " now " + now.toString());
+ // CMS.debug("notBefore " + notBefore.toString() + " now " +
+ // now.toString());
if (notBefore.after(now)) {
CMS.debug("Record does not qualify,notBefore " + notBefore.toString() + " date " + now.toString());
continue;
@@ -600,8 +592,9 @@ public class CertificateRepository extends Repository
updateStatus(serial, newCertStatus);
if (newCertStatus.equals(CertRecord.STATUS_REVOKED_EXPIRED)) {
-
- // inform all CRLIssuingPoints about revoked and expired certificate
+
+ // 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>();
@@ -833,18 +829,16 @@ public class CertificateRepository extends Repository
}
/**
- * Finds a list of certificate records that satisifies
- * the filter.
- * If you are going to process everything in the list,
- * use this.
+ * Finds a list of certificate records that satisifies the filter. If you
+ * are going to process everything in the list, use this.
*/
public Enumeration findCertRecords(String filter)
- throws EBaseException {
+ throws EBaseException {
IDBSSession s = mDBService.createSession();
Enumeration e = null;
try {
- //e = s.search(getDN(), filter);
+ // e = s.search(getDN(), filter);
ICertRecordList list = null;
list = findCertRecordsInList(filter, null, "serialno", 10);
@@ -852,15 +846,16 @@ public class CertificateRepository extends Repository
e = list.getCertRecords(0, size - 1);
} finally {
- if (s != null)
+ if (s != null)
s.close();
}
return e;
}
/**
- * Finds certificate records. Here is a list of filter
- * attribute can be used:
+ * Finds certificate records. Here is a list of filter attribute can be
+ * used:
+ *
* <pre>
* certRecordId
* certMetaInfo
@@ -871,49 +866,50 @@ public class CertificateRepository extends Repository
* x509Cert.notAfter
* x509Cert.subject
* </pre>
- * The filter should follow RFC1558 LDAP filter syntax.
- * For example,
+ *
+ * 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 +917,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 +951,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 +966,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 +1014,7 @@ public class CertificateRepository extends Repository
public class RenewableCertificateCollection {
Vector<Object> mToRenew = null;
Vector<Object> mToNotify = null;
+
public RenewableCertificateCollection() {
}
@@ -1044,21 +1041,21 @@ 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 + ")))";
- //Enumeration e = s.search(getDN(), filter);
+ 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;
list = findCertRecordsInList(filter, null, "serialno", 10);
@@ -1077,7 +1074,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,23 +1083,22 @@ public class CertificateRepository extends Repository
}
}
} finally {
- if (s != null)
+ if (s != null)
s.close();
}
return tab;
}
/**
- * 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.
+ * 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.
* @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 +1106,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 += ")(" +
@@ -1126,7 +1122,7 @@ public class CertificateRepository extends Repository
}
filter += "))";
- //Enumeration e = s.search(getDN(), filter);
+ // Enumeration e = s.search(getDN(), filter);
ICertRecordList list = null;
list = findCertRecordsInList(filter, null, "serialno", 10);
@@ -1145,14 +1141,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;
@@ -1161,7 +1157,7 @@ public class CertificateRepository extends Repository
Enumeration e = null;
if (filter != null && filter.length() > 0) {
- //e = s.search(getDN(), filter);
+ // e = s.search(getDN(), filter);
ICertRecordList list = null;
list = findCertRecordsInList(filter, null, "serialno", 10);
@@ -1182,7 +1178,7 @@ public class CertificateRepository extends Repository
v.copyInto(certs);
}
} finally {
- if (s != null)
+ if (s != null)
s.close();
}
return certs;
@@ -1190,106 +1186,108 @@ 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) + "))";
- //e = s.search(getDN(), ldapfilter);
+ 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;
list = findCertRecordsInList(ldapfilter, null, "serialno", 10);
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
- * excluding ones already revoked.
- * @param from The starting point of the serial number range.
- * @param to The ending point of the serial number range.
+ * 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.
*/
public Enumeration getValidNotPublishedCertificates(String from, String to)
- throws EBaseException {
+ throws EBaseException {
IDBSSession s = mDBService.createSession();
Enumeration e = null;
@@ -1311,53 +1309,53 @@ public class CertificateRepository extends Repository
"certMetainfo=" +
CertRecord.META_LDAPPUBLISH +
":true)))";
- //e = s.search(getDN(), ldapfilter);
+ // 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 {
- if (s != null)
+ if (s != null)
s.close();
}
return e;
}
/**
- * Retrives all valid not published certificates
- * excluding ones already revoked.
+ * 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)))";
- //e = s.search(getDN(), ldapfilter);
+ 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;
list = findCertRecordsInList(ldapfilter, null, "serialno", 10);
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 +1363,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;
@@ -1384,17 +1383,17 @@ public class CertificateRepository extends Repository
ldapfilter += "!(" + CertRecord.ATTR_X509CERT + "." +
CertificateValidity.NOT_AFTER + ">=" +
DateMapper.dateToDB(now) + ")))";
- //e = s.search(getDN(), ldapfilter);
-
+ // 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,26 +1403,26 @@ 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) + "))";
- //e = s.search(getDN(), ldapfilter);
+ 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;
@@ -1431,11 +1430,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;
@@ -1449,22 +1449,22 @@ public class CertificateRepository extends Repository
ldapfilter += CertRecord.ATTR_ID + "<=" + to + ")(";
ldapfilter += "!(" + CertRecord.ATTR_X509CERT + "." +
CertificateValidity.NOT_AFTER + ">=" +
- //DateMapper.dateToDB(now) + ")))";
+ // DateMapper.dateToDB(now) + ")))";
DateMapper.dateToDB(now) + "))(" +
"certMetainfo=" +
CertRecord.META_LDAPPUBLISH +
":true))";
- //e = s.search(getDN(), ldapfilter);
-
+ // 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 +1474,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,25 +1488,25 @@ public class CertificateRepository extends Repository
ldapfilter += "(certMetainfo=" +
CertRecord.META_LDAPPUBLISH +
":true))";
-
- //e = s.search(getDN(), ldapfilter);
+
+ // 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;
}
public ICertRecordList getInvalidCertsByNotBeforeDate(Date date, int pageSize)
- throws EBaseException {
+ throws EBaseException {
String now = null;
@@ -1521,22 +1521,21 @@ 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);
- //e = s.search(getDN(), ldapfilter);
+ // e = s.search(getDN(), ldapfilter);
CMS.debug("getInvalidCertificatesByNotBeforeDate: about to call findCertRecordsInList");
list = findCertRecordsInListRawJumpto(ldapfilter, attrs,
DateMapper.dateToDB(date), "notBefore", pageSize);
- //e = list.getCertRecords(0, size - 1);
+ // e = list.getCertRecords(0, size - 1);
} finally {
// XXX - transaction is not done at this moment
-
CMS.debug("In getInvalidCertsByNotBeforeDate finally.");
if (s != null)
@@ -1547,7 +1546,7 @@ public class CertificateRepository extends Repository
}
public ICertRecordList getValidCertsByNotAfterDate(Date date, int pageSize)
- throws EBaseException {
+ throws EBaseException {
String now = null;
@@ -1560,11 +1559,11 @@ 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);
- //e = s.search(getDN(), ldapfilter);
+ // e = s.search(getDN(), ldapfilter);
list = findCertRecordsInListRawJumpto(ldapfilter, attrs, DateMapper.dateToDB(date), "notAfter", pageSize);
} finally {
@@ -1577,7 +1576,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,11 +1588,11 @@ 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);
- //e = s.search(getDN(), ldapfilter);
+ // e = s.search(getDN(), ldapfilter);
CMS.debug("getRevokedCertificatesByNotAfterDate: about to call findCertRecordsInList");
list = findCertRecordsInListRawJumpto(ldapfilter, attrs,
@@ -1602,21 +1601,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;
@@ -1628,7 +1627,7 @@ public class CertificateRepository extends Repository
if (to != null && to.length() > 0)
ldapfilter += "(" + CertRecord.ATTR_ID + "<=" + to + ")";
ldapfilter += ")";
- //e = s.search(getDN(), ldapfilter);
+ // e = s.search(getDN(), ldapfilter);
ICertRecordList list = null;
list = findCertRecordsInList(ldapfilter, null, "serialno", 10);
@@ -1637,24 +1636,29 @@ 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
- * not yet valid.
+ * 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
+ String ldapfilter = "(|(" + CertRecord.ATTR_CERT_STATUS + "=" + CertRecord.STATUS_REVOKED + ")(" + CertRecord.ATTR_CERT_STATUS + "=" + CertRecord.STATUS_REVOKED_EXPIRED + "))"; // index
+ // is
+ // setup
+ // for
+ // this
+ // filter
try {
- //e = s.search(getDN(), ldapfilter);
+ // e = s.search(getDN(), ldapfilter);
ICertRecordList list = null;
list = findCertRecordsInList(ldapfilter, null, "serialno", 10);
@@ -1662,19 +1666,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,11 +1690,11 @@ 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))";
- //e = s.search(getDN(), ldapfilter);
+ // e = s.search(getDN(), ldapfilter);
ICertRecordList list = null;
list = findCertRecordsInList(ldapfilter, null, "serialno", 10);
@@ -1698,27 +1703,32 @@ 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
- * already expired or not yet valid.
+ * 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
+ String ldapfilter = "(&(|(" + CertRecord.ATTR_CERT_STATUS + "=" + CertRecord.STATUS_REVOKED + ")(" + CertRecord.ATTR_CERT_STATUS + "=" + CertRecord.STATUS_REVOKED_EXPIRED + "))"; // index
+ // is
+ // setup
+ // for
+ // this
+ // filter
ldapfilter += "(certMetainfo=" +
CertRecord.META_LDAPPUBLISH +
":true))";
try {
- //e = s.search(getDN(), ldapfilter);
+ // e = s.search(getDN(), ldapfilter);
ICertRecordList list = null;
list = findCertRecordsInList(ldapfilter, null, "serialno", 10);
@@ -1726,30 +1736,31 @@ 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;
try {
- /*e = s.search(getDN(), "(&(" +
- CertRecord.ATTR_REVO_INFO + "=*)(" + CertRecord.ATTR_X509CERT +
- "." + CertificateValidity.NOT_AFTER + " >= " +
- DateMapper.dateToDB(asOfDate) + "))");*/
+ /*
+ * e = s.search(getDN(), "(&(" + CertRecord.ATTR_REVO_INFO + "=*)("
+ * + CertRecord.ATTR_X509CERT + "." + 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 +1769,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,13 +1779,18 @@ 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
+ String ldapfilter = "(" + CertRecord.ATTR_CERT_STATUS + "=" + CertRecord.STATUS_REVOKED + ")"; // index
+ // is
+ // setup
+ // for
+ // this
+ // filter
try {
- //e = s.search(getDN(), ldapfilter);
+ // e = s.search(getDN(), ldapfilter);
ICertRecordList list = null;
list = findCertRecordsInList(ldapfilter, null, "serialno", 10);
@@ -1782,14 +1798,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 +1815,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 +1825,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 +1850,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 +1867,16 @@ public class CertificateRepository extends Repository
}
}
-
/**
- * Checks if the presented certificate belongs to the repository
- * and is revoked.
- *
- * @param cert certificate to verify.
- * @return RevocationInfo if the presented certificate is revoked otherwise null.
+ * Checks if the presented certificate belongs to the repository and is
+ * revoked.
+ *
+ * @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 +1901,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++) {
@@ -1905,15 +1921,14 @@ public class CertificateRepository extends Repository
}
public void shutdown() {
- //if (mCertStatusUpdateThread != null)
- // mCertStatusUpdateThread.destroy();
+ // if (mCertStatusUpdateThread != null)
+ // mCertStatusUpdateThread.destroy();
- //if (mRetrieveModificationsThread != null)
- // mRetrieveModificationsThread.destroy();
+ // if (mRetrieveModificationsThread != null)
+ // mRetrieveModificationsThread.destroy();
}
}
-
class CertStatusUpdateThread extends Thread {
CertificateRepository _cr = null;
IRepository _rr = null;
@@ -1922,7 +1937,7 @@ class CertStatusUpdateThread extends Thread {
CertStatusUpdateThread(CertificateRepository cr, IRepository rr, String name) {
super(name);
CMS.debug("new CertStatusUpdateThread");
- //setName(name);
+ // setName(name);
_cr = cr;
_rr = rr;
@@ -1965,7 +1980,6 @@ class CertStatusUpdateThread extends Thread {
}
}
-
class RetrieveModificationsThread extends Thread {
CertificateRepository _cr = null;
LDAPSearchResults _results = null;
@@ -1973,7 +1987,7 @@ class RetrieveModificationsThread extends Thread {
RetrieveModificationsThread(CertificateRepository cr, String name) {
super(name);
CMS.debug("new RetrieveModificationsThread");
- //setName(name);
+ // setName(name);
_cr = cr;
}
@@ -1992,7 +2006,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 65b1039d..21974918 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,18 @@ 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
- * 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.
- *
+ * A class represents a registry where all the 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 {
@@ -79,25 +74,24 @@ public class DBRegistry implements IDBRegistry, ISubsystem {
}
/**
- * Sets subsystem identifier. This is an internal
- * subsystem, and is not loadable.
+ * Sets subsystem identifier. This is an internal subsystem, and is not
+ * loadable.
*/
public void setId(String id) throws EBaseException {
throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_OPERATION"));
}
/**
- * 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.
+ * 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,24 +122,27 @@ 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
- *
+ /*
+ * LogDoc
+ *
* @phase db startup
+ *
* @reason failed to register object class
+ *
* @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 +158,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);
@@ -180,9 +177,9 @@ public class DBRegistry implements IDBRegistry, ISubsystem {
}
/**
- * Creates LDAP-based search filters with help of
- * registered mappers.
- * Parses filter from filter string specified in RFC1558.
+ * 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 +206,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 +271,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 +315,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 +323,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,27 +338,26 @@ 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);
}
/**
- * Retrieves a list of LDAP attributes that are associated
- * with the given attributes.
- * This method is used for searches, to map the database attributes
- * to LDAP attributes.
+ * Retrieves a list of LDAP attributes that are associated with the given
+ * attributes. 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 +387,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;
@@ -403,14 +398,17 @@ public class DBRegistry implements IDBRegistry, ISubsystem {
if (matchingDynAttrMapper != null) {
v.addElement(attrs[i]);
} else {
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @phase retrieve ldap attr
+ *
* @reason failed to get registered object class
+ *
* @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,17 +451,17 @@ 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");
- //CMS.debug("createObject: attrs " + attrs.toString());
+ // CMS.debug("createObject: attrs " + attrs.toString());
attrs.remove("objectclass");
// 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,27 +486,30 @@ 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) {
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @phase create ldap attr
+ *
* @reason failed to create object class
+ *
* @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 +544,6 @@ public class DBRegistry implements IDBRegistry, ISubsystem {
}
}
-
/**
* Just a convenient container class.
*/
@@ -556,7 +556,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 5b081d6c..b2a3b17f 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,12 @@ 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.
- *
+ * 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 +63,7 @@ public class DBSSession implements IDBSSession {
/**
* Constructs a database session.
- *
+ *
* @param system the database subsytem
* @param c the ldap connection
*/
@@ -75,7 +72,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,28 +94,31 @@ 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(&quot;cn=123459,o=certificate repository,o=airius.com&quot;,
+ * 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
- *
+ /*
+ * LogDoc
+ *
* @phase local ldap add
+ *
* @message DBSSession: begin LDAP add <entry>
*/
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",
@@ -127,9 +127,8 @@ public class DBSSession implements IDBSSession {
}
/**
- * Reads an object from the database.
- * all attributes will be returned
- *
+ * 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 {
@@ -137,14 +136,14 @@ public class DBSSession implements IDBSSession {
}
/**
- * Reads an object from the database, and only populates
- * the selected attributes.
- *
+ * 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;
@@ -153,9 +152,11 @@ public class DBSSession implements IDBSSession {
).getLDAPAttributes(attrs);
}
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @phase local ldap read
+ *
* @message DBSSession: begin LDAP read <entry>
*/
LDAPSearchResults res = mConn.search(name,
@@ -167,16 +168,18 @@ public class DBSSession implements IDBSSession {
entry.getAttributeSet());
} catch (LDAPException e) {
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @phase local ldap read
+ *
* @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 +194,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,36 +206,38 @@ 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());
}
}
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @phase local ldap add
+ *
* @message DBSSession: begin LDAP modify <entry>
*/
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",
@@ -256,20 +261,19 @@ public class DBSSession implements IDBSSession {
}
/**
- * Searchs for a list of objects that match the
- * filter.
+ * Searchs for a list of objects that match the 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 +285,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,22 +313,21 @@ 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()));
}
}
/**
- * Retrieves a list of object that satifies the given
- * filter.
+ * Retrieves a list of object that satifies the given filter.
*/
public IDBSearchResults search(String base, String filter,
- String attrs[]) throws EBaseException {
+ String attrs[]) throws EBaseException {
try {
String ldapattrs[] = null;
@@ -333,35 +336,37 @@ public class DBSSession implements IDBSSession {
).getLDAPAttributes(attrs);
}
String ldapfilter =
- mDBSystem.getRegistry().getFilter(filter);
+ mDBSystem.getRegistry().getFilter(filter);
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @phase local ldap add
+ *
* @message DBSSession: begin LDAP search <filter>
*/
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,11 +374,11 @@ 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.
+ // Only version 3 protocol supports persistent search.
if (version.intValue() == 2) {
mConn.setOption(LDAPv2.PROTOCOL_VERSION, Integer.valueOf(3));
}
@@ -384,22 +389,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 +414,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 +423,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 +432,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 +441,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,21 +450,21 @@ 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);
}
/**
- * Releases object to this interface. This allows us to
- * use memory more efficiently.
+ * Releases object to this interface. This allows us to use memory more
+ * efficiently.
*/
public void release(Object obj) {
// not implemented
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 123fb847..e18906ff 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,12 @@
// --- 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.
- *
+ * 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 8b5098dc..1fadbbf5 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,13 @@ 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.
- *
+ * 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,24 +68,27 @@ 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) {
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @phase local ldap search
+ *
* @reason failed to get next element
+ *
* @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 3208a23d..16fbecbc 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,15 @@ 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.
- *
+ * 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 +95,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 +137,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 +167,10 @@ public class DBSubsystem implements IDBSubsystem {
}
/**
- * 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.
+ * 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.
*/
public static void setInstance(IDBSubsystem dbSubsystem) {
mInstance = dbSubsystem;
@@ -191,7 +189,7 @@ public class DBSubsystem implements IDBSubsystem {
*/
public String getId() {
return IDBSubsystem.SUB_ID;
- }
+ }
/**
* Sets subsystem identifier.
@@ -214,14 +212,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 +230,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 +261,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,28 +301,27 @@ 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);
- //persist to file
+ // persist to file
mDBConfig.putString((String) h.get(PROP_MAX_NAME), serial);
IConfigStore rootStore = getOwner().getConfigStore();
rootStore.commit(false);
@@ -339,17 +332,17 @@ 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);
- //persist to file
+ // persist to file
mDBConfig.putString((String) h.get(PROP_MIN_NAME), serial);
IConfigStore rootStore = getOwner().getConfigStore();
rootStore.commit(false);
@@ -360,13 +353,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 +380,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,19 +398,19 @@ 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;
}
/**
- * 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
+ * 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
* @return start of next range
*/
public String getNextRange(int repo) {
@@ -430,28 +423,29 @@ 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 );
+ // 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);
// 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());
}
}
@@ -475,31 +468,30 @@ 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
- * below the low water mark, then a new range will be requested.
+ * 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 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,12 @@ public class DBSubsystem implements IDBSubsystem {
}
/**
- * 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.
+ * 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 +537,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 +676,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 +684,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 +746,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 +808,7 @@ public class DBSubsystem implements IDBSubsystem {
*/
public void startup() throws EBaseException {
}
-
+
/**
* Retrieves configuration store.
*/
@@ -861,16 +849,19 @@ public class DBSubsystem implements IDBSubsystem {
}
} catch (ELdapException e) {
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @phase shutdown server
+ *
* @reason shutdown db subsystem
+ *
* @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 +896,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) {
@@ -928,25 +919,26 @@ public class DBSubsystem implements IDBSubsystem {
CMS.getUserMessage("CMS_DBS_INTERNAL_DIR_UNAVAILABLE"));
}
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @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 ddec63ce..350c78b6 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
+ * A class represents a virtual list of search results. Note that this class
+ * must be used with DS4.0.
+ *
+ * @author thomask
* @author mzhao
* @version $Revision$, $Date$
*/
@@ -71,63 +69,62 @@ 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.
- * 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
- * param filter search filter specifying the search criteria
- * param attrs list of attributes that you want returned in the search results
+ * 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 param filter search filter specifying
+ * the search criteria 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()));
}
}
/**
- * 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
- * param filter search filter specifying the search criteria
- * param attrs list of attributes that you want returned in the search results
- * param sortKey the attributes to sort by
+ * 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 param filter search filter specifying
+ * the search criteria param attrs list of attributes that you want returned
+ * in the search results 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;
@@ -137,27 +134,26 @@ 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
- * param filter search filter specifying the search criteria
- * param attrs list of attributes that you want returned in the search results
- * param sortKey the attribute to sort by
+ * 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 param filter search filter specifying
+ * the search criteria param attrs list of attributes that you want returned
+ * in the search results 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,29 +164,28 @@ 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
- * param filter search filter specifying the search criteria
- * 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
+ *
+ * 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 param filter search filter specifying
+ * the search criteria 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
*/
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,23 +197,22 @@ 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
- * param filter search filter specifying the search criteria
- * 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
+ *
+ * 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 param filter search filter specifying
+ * the search criteria 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
*/
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 +229,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 +254,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
if (pageSize < 0) {
mJumpToDirection = -1;
- }
+ }
mPageSize = pageSize;
mBeforeCount = 0;
@@ -268,11 +262,10 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
}
/**
- * Set the paging size of this virtual list.
- * The page size here is just a buffer size. A buffer is kept around
- * that is three times as large as the number of visible entries.
- * That way, you can scroll up/down several items(up to a page-full)
- * without refetching entries from the directory.
+ * Set the paging size of this virtual list. The page size here is just a
+ * buffer size. A buffer is kept around that is three times as large as the
+ * number of visible entries. That way, you can scroll up/down several
+ * items(up to a page-full) without refetching entries from the directory.
*
* @param size the page size
*/
@@ -283,15 +276,16 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
}
mPageSize = size;
- mBeforeCount = 0; //mPageSize;
+ mBeforeCount = 0; // mPageSize;
mAfterCount = mPageSize; // mPageSize + mPageSize;
- //CMS.debug("In setPageSize " + size + " mBeforeCount " + mBeforeCount + " mAfterCount " + mAfterCount);
+ // CMS.debug("In setPageSize " + size + " mBeforeCount " + mBeforeCount
+ // + " mAfterCount " + mAfterCount);
}
/**
* set the sort key
- *
+ *
* @param sortKey the attribute to sort by
*/
public void setSortKey(String sortKey) throws EBaseException {
@@ -303,7 +297,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 {
@@ -319,28 +313,31 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
}
} catch (Exception e) {
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @phase local ldap search
+ *
* @reason Failed at setSortKey.
+ *
* @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()
- * since you'd better check if the index is out of bound first.
+ * Retrieves the size of this virtual list. Recommend to call getSize()
+ * before getElementAt() or getElements() since you'd better check if the
+ * index is out of bound first.
*/
public int getSize() {
if (!mInitialized) {
@@ -348,16 +345,18 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
// Do an initial search to get the virtual list size
// Keep one page before and one page after the start
if (mJumpTo == null) {
- mBeforeCount = 0; //mPageSize;
- mAfterCount = mPageSize; // mPageSize + mPageSize;
+ mBeforeCount = 0; // mPageSize;
+ mAfterCount = mPageSize; // mPageSize + mPageSize;
}
// Create the initial paged results control
- /* Since this one is only used to get the size of the virtual list;
- we don't care about the starting index. If there is no partial
- match, the first one before (or after, if none before) is returned
- as the index entry. Instead of "A", you could use the other
- constructor and specify 0 both for startIndex and for
- contentCount. */
+ /*
+ * Since this one is only used to get the size of the virtual list;
+ * we don't care about the starting index. If there is no partial
+ * match, the first one before (or after, if none before) is
+ * returned as the index entry. Instead of "A", you could use the
+ * other constructor and specify 0 both for startIndex and for
+ * contentCount.
+ */
LDAPVirtualListControl cont = null;
if (mJumpTo == null) {
@@ -368,7 +367,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 +381,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 +409,7 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
return size;
}
-
+
private synchronized boolean getEntries() {
// Specify necessary controls for vlist
// LDAPSearchConstraints cons = mConn.getSearchConstraints();
@@ -419,13 +418,13 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
cons.setMaxResults(0);
if (mPageControls != null) {
cons.setServerControls(mPageControls);
- //System.out.println( "setting vlist control" );
+ // System.out.println( "setting vlist control" );
}
// Empty the buffer
mEntries.removeAllElements();
// Do a search
try {
- //what happen if there is no matching?
+ // what happen if there is no matching?
String ldapFilter = mRegistry.getFilter(mFilter);
String ldapAttrs[] = null;
LDAPSearchResults result;
@@ -434,12 +433,10 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
ldapAttrs = mRegistry.getLDAPAttributes(mAttrs);
/*
- LDAPv2.SCOPE_BASE:
- (search only the base DN)
- LDAPv2.SCOPE_ONE:
- (search only entries under the base DN)
- LDAPv2.SCOPE_SUB:
- (search the base DN and all entries within its subtree)
+ * LDAPv2.SCOPE_BASE: (search only the base DN)
+ * LDAPv2.SCOPE_ONE: (search only entries under the base DN)
+ * LDAPv2.SCOPE_SUB: (search the base DN and all entries within
+ * its subtree)
*/
result = mConn.search(mBase,
LDAPConnection.SCOPE_ONE, ldapFilter, ldapAttrs,
@@ -459,47 +456,53 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
LDAPEntry entry = (LDAPEntry) result.nextElement();
try {
- //maintain mEntries as vector of LDAPEntry
+ // 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) {
CMS.debug("Exception " + e);
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @phase local ldap search
+ *
* @reason Failed to get enties.
+ *
* @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;
}
}
}
} catch (Exception e) {
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @phase local ldap search
+ *
* @reason Failed to get enties.
+ *
* @message DBVirtualList: <exception thrown>
*/
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" );
+ // System.out.println( "Returning " + mEntries.size() +
+ // " entries" );
CMS.debug("getEntries returning " + mEntries.size());
return true;
@@ -515,10 +518,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;
@@ -533,10 +536,10 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
mSize = nextCont.getContentCount();
((LDAPVirtualListControl) mPageControls[1]).setListSize(mSize);
mInitialized = true;
- //System.out.println( "Virtual window: " + mTop +
- // ".." + (mTop+mEntries.size()-1) +
- // " of " + mSize );
- } else {
+ // System.out.println( "Virtual window: " + mTop +
+ // ".." + (mTop+mEntries.size()-1) +
+ // " of " + mSize );
+ } else {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_DB, ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_DBS_VL_NULL_RESPONSE"));
}
return true;
@@ -546,14 +549,15 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
}
}
- /** Get a page starting at "first" (although we may also fetch
- * some preceding entries)
- * Recommend to call getSize() before getElementAt() or getElements()
- * since you'd better check if the index is out of bound first.
- *
+ /**
+ * Get a page starting at "first" (although we may also fetch some preceding
+ * entries) 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,
@@ -563,116 +567,131 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
mPageControls[1] = cont;
}
- //CMS.debug("about to set range first " + first + " mBeforeCount " + mBeforeCount + " mAfterCount " + mAfterCount);
+ // CMS.debug("about to set range first " + first + " mBeforeCount " +
+ // mBeforeCount + " mAfterCount " + mAfterCount);
((LDAPVirtualListControl) mPageControls[1]).setRange(first, mBeforeCount, mAfterCount);
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;
mTop = Math.max(0, mSelectedIndex - mBeforeCount);
- //CMS.debug("New mTop: " + mTop + " mSelectedIndex " + mSelectedIndex);
+ // CMS.debug("New mTop: " + mTop + " mSelectedIndex " +
+ // mSelectedIndex);
// Now we know the total size of the virtual list box
mSize = nextCont.getContentCount();
((LDAPVirtualListControl) mPageControls[1]).setListSize(mSize);
mInitialized = true;
- //System.out.println( "Virtual window: " + mTop +
- // ".." + (mTop+mEntries.size()-1) +
- // " of " + mSize );
+ // System.out.println( "Virtual window: " + mTop +
+ // ".." + (mTop+mEntries.size()-1) +
+ // " of " + mSize );
} else {
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @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.
- * 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
- *
+ /**
+ * 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);
- //System.out.println( "Setting requested start to " +
- // 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()
- * 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
- *
+ /**
+ * fetch data of a single list item 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) {
- /* mSize may not be init at this time! Bad !
- * the caller should really check the index is within bound before this
- * but I'll take care of this just in case they are too irresponsible
+ /*
+ * mSize may not be init at this time! Bad ! the caller should really
+ * check the index is within bound before this but I'll take care of
+ * this just in case they are too irresponsible
*/
int baseJumpTo = 0;
if (!mInitialized)
mSize = getSize();
- CMS.debug("getElementAt: " + index + " mTop " + mTop);
-
- //System.out.println( "need entry " + index );
+ 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 +700,16 @@ 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);
@@ -702,21 +722,24 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
}
}
- //CMS.debug("getElementAt noJumpto: " + index);
+ // CMS.debug("getElementAt noJumpto: " + index);
- 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 );
- // CMS.debug("getElementAt noJumpto: getting page index: " + index + " mEntries.size() " + mEntries.size() + " mTop: " + mTop);
+ 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 );
+ // CMS.debug("getElementAt noJumpto: getting page index: " + index +
+ // " mEntries.size() " + mEntries.size() + " mTop: " + mTop);
getPage(index);
}
int offset = index - mTop;
if ((offset < 0) || (offset >= mEntries.size()))
- //XXX
- return null; //("No entry at " + index);
+ // XXX
+ return null; // ("No entry at " + index);
else
return mEntries.elementAt(offset);
}
@@ -726,20 +749,21 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
}
/**
- * This function processes elements as soon as it arrives. It is
- * more memory-efficient.
+ * This function processes elements as soon as it arrives. It is 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
- * but I'll take care of this just in case they are too irresponsible
+ /*
+ * mSize may not be init at this time! Bad ! the caller should really
+ * check the index is within bound before this but I'll take care of
+ * this just in case they are too irresponsible
*/
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);
@@ -750,10 +774,10 @@ public class DBVirtualList<E> implements IDBVirtualList<E> {
return;
}
- //guess this is what you really mean to try to improve performance
+ // 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 +790,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 b8df1240..d0ea2384 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,12 @@ 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.
- *
+ * 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 +58,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)
@@ -77,11 +74,10 @@ public class DateArrayMapper implements IDBAttrMapper {
}
/**
- * Maps LDAP attributes into object, and put the object
- * into 'parent'.
+ * 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 +100,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 d547a445..0094159b 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,10 @@ 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.
- *
+ * 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 +42,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,18 +63,17 @@ 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)));
}
/**
- * Maps LDAP attributes into object, and put the object
- * into 'parent'.
+ * Maps LDAP attributes into object, and put the object 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 +86,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 c5601a9b..2de316c6 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,12 @@ 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.
- *
+ * 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,19 +57,18 @@ 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()));
}
/**
- * Maps LDAP attributes into object, and put the object
- * into 'parent'.
+ * 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 +80,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 ff776424..e940a530 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,10 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.dbs;
-
-
-
/**
- * A class represents a collection of key record
- * specific schema information.
+ * A class represents a collection of key record specific schema information.
* <P>
- *
+ *
* @author thomask
* @version $Revision$, $Date$
*/
@@ -43,9 +39,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 2c1265f7..eb16032b 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,12 @@ 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.
+ * 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$
*/
@@ -82,14 +79,14 @@ public class KeyRecord implements IDBObj, IKeyRecord {
}
/*
- * Constructs key record.
+ * Constructs key record.
*
* @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;
@@ -193,10 +190,10 @@ public class KeyRecord implements IDBObj, IKeyRecord {
}
/**
- * Retrieves serial number of the key record. Each key record
- * is uniquely identified by serial number.
+ * 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 +208,9 @@ public class KeyRecord implements IDBObj, IKeyRecord {
}
/**
- * Retrieves the key state. This gives key life cycle
- * information.
+ * Retrieves the key state. This gives key life cycle information.
* <P>
- *
+ *
* @return key state
*/
public KeyState getState() throws EBaseException {
@@ -239,7 +235,7 @@ public class KeyRecord implements IDBObj, IKeyRecord {
/**
* Retrieves key.
* <P>
- *
+ *
* @return archived key
*/
public byte[] getPrivateKeyData() throws EBaseException {
@@ -256,7 +252,7 @@ public class KeyRecord implements IDBObj, IKeyRecord {
/**
* Retrieves the key size.
* <P>
- *
+ *
* @return key size
*/
public Integer getKeySize() throws EBaseException {
@@ -280,7 +276,7 @@ public class KeyRecord implements IDBObj, IKeyRecord {
}
/**
- * Sets owner name.
+ * Sets owner name.
* <P>
*/
public void setOwnerName(String name) throws EBaseException {
@@ -338,8 +334,7 @@ public class KeyRecord implements IDBObj, IKeyRecord {
}
/**
- * Retrieves the last modification time of
- * this record.
+ * Retrieves the last modification time of this record.
*/
public Date getModifyTime() {
return mModifyTime;
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 f4882ffc..dd0c88a9 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 1cbd3229..9218abfd 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,12 @@ 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
- * key record into database.
+ * 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 +56,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;
@@ -68,47 +65,51 @@ public class KeyRecordMapper implements IDBAttrMapper {
rec.getSerialNumber().toString()));
} catch (Exception e) {
- /*LogDoc
- *
- * @phase Maps object to ldap attribute set
+ /*
+ * LogDoc
+ *
+ * @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);
} catch (Exception e) {
- /*LogDoc
- *
- * @phase Maps ldap attribute set to object
+ /*
+ * LogDoc
+ *
+ * @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 f684718c..c1278888 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,10 @@ 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.
+ * A class represents a Key repository. This is the container of archived keys.
* <P>
- *
+ *
* @author thomask
* @version $Revision$, $Date$
*/
@@ -59,15 +56,15 @@ public class KeyRepository extends Repository implements IKeyRepository {
private String mBaseDN = null;
/**
- * Constructs a key repository. It checks if the key repository
- * does exist. If not, it creates the repository.
+ * 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 +78,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 +144,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 +168,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 +183,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 +192,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 +231,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 +260,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 +271,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 +313,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 +359,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 +373,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 +390,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 +405,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,92 +426,91 @@ 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;
}
public void shutdown() {
- //if (mKeyStatusUpdateThread != null)
- // mKeyStatusUpdateThread.destroy();
+ // if (mKeyStatusUpdateThread != null)
+ // mKeyStatusUpdateThread.destroy();
}
}
@@ -538,7 +544,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 +559,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 7f13c8ed..3da1c795 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,19 +50,18 @@ 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()));
}
/**
- * Maps LDAP attributes into object, and put the object
- * into 'parent'.
+ * 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 +74,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 909bf47e..1b7b9381 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,12 @@ 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.
+ * 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 cdd9aeb7..a97f2703 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,12 @@ 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.
- *
+ * 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,19 +57,18 @@ 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)));
}
/**
- * Maps LDAP attributes into object, and put the object
- * into 'parent'.
+ * 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 +80,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 605e2fad..8cd0656e 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:
- *
+ * 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();
@@ -92,11 +90,10 @@ public class MetaInfoMapper implements IDBAttrMapper {
}
/**
- * Maps LDAP attributes into object, and put the object into
- * 'parent'.
+ * Maps LDAP attributes into object, and put the object 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)
@@ -114,12 +111,11 @@ public class MetaInfoMapper implements IDBAttrMapper {
}
/**
- * Map search filters into LDAP search filter.
- * Possible search filter:
+ * Map search filters into LDAP search filter. Possible search filter:
* (&(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 46979715..f0aa6936 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,13 @@ 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.
- *
+ * 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 +66,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,35 +76,36 @@ 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) {
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @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));
}
}
/**
- * Maps LDAP attributes into object, and put the object
- * into 'parent'.
+ * 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 8a2d1f2d..88aeda3a 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,14 @@ 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.
+ * 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,18 +65,17 @@ 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));
}
/**
- * Maps LDAP attributes into object, and put the object
- * into 'parent'.
+ * 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) {
@@ -89,11 +85,11 @@ public class PublicKeyMapper implements IDBAttrMapper {
}
/**
- * Maps search filters into LDAP search filter. It knows
- * how to extract public key from the certificate.
+ * 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) {
@@ -111,14 +107,16 @@ public class PublicKeyMapper implements IDBAttrMapper {
return mLdapName + op + escapeBinaryData(pub);
} catch (Exception e) {
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @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 61beb423..4e79cd89 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;
@@ -27,15 +26,15 @@ import com.netscape.certsrv.dbs.IDBSubsystem;
import com.netscape.certsrv.dbs.replicadb.IReplicaIDRepository;
/**
- * A class represents a replica repository. It
- * creates unique managed replica IDs.
+ * 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 858e7a63..494da26c 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
- * serial number within repository.
+ * 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,45 @@ 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 +126,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,21 +136,23 @@ 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();
if (!mInit) {
- // cms may crash after issue a cert but before update
+ // cms may crash after issue a cert but before update
// the serial number record
try {
IDBObj obj = s.read("cn=" +
@@ -168,7 +162,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 +173,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 +205,8 @@ public abstract class Repository implements IRepository {
maxSerial = new BigInteger(serial, mRadix);
if (maxSerial != null) {
- mMaxSerial = serial;
- mMaxSerialNo = maxSerial;
+ mMaxSerial = serial;
+ mMaxSerialNo = maxSerial;
}
}
@@ -229,7 +223,8 @@ public abstract class Repository implements IRepository {
* Set the maximum serial number in next range
*
* @param serial maximum number in next range
- * @exception EBaseException failed to set maximum serial number in next range
+ * @exception EBaseException failed to set maximum serial number in next
+ * range
*/
public void setNextMaxSerial(String serial) throws EBaseException {
BigInteger maxSerial = null;
@@ -237,23 +232,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,16 +255,17 @@ 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) {
- // Key Repository uses the same configuration parameters as Certificate
- // Repository. This is ok because they are on separate subsystems.
+ } 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");
mRadix = 16;
mRepo = IDBSubsystem.CERTS;
@@ -278,7 +273,8 @@ public abstract class Repository implements IRepository {
CMS.debug("Repository: Instance of Replica ID repository");
mRepo = IDBSubsystem.REPLICA_ID;
} else {
- // CRLRepository subclasses this too, but does not use serial number stuff
+ // CRLRepository subclasses this too, but does not use serial number
+ // stuff
CMS.debug("Repository: Instance of Request Repository or CRLRepository.");
mRepo = IDBSubsystem.REQUESTS;
}
@@ -292,48 +288,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 +341,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 {
@@ -370,46 +365,45 @@ public abstract class Repository implements IRepository {
}
/**
- * Retrieves the next serial number, and also increase the
- * serial number by one.
+ * 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 +420,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
- * current range, or if a range conflict has occurred.
- *
+ * 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 +457,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 +471,29 @@ 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
+ * Sets whether serial number management is enabled for certs 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 97cedac8..0a79b4b9 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 67cc5c1c..a926187f 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,10 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.dbs;
-
-
-
/**
- * A class represents a collection of repository-specific
- * schema information.
+ * 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 001089fb..87da8b91 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
- * which essentially signifies a revocation act.
+ * A class represents a certificate revocation info. This object is written as
+ * an attribute of certificate record which essentially signifies a revocation
+ * act.
* <P>
- *
+ *
* @author galperin
* @version $Revision$, $Date$
*/
@@ -52,11 +50,10 @@ public class RevocationInfo implements IRevocationInfo, Serializable {
}
/**
- * Constructs revocation info used by revocation
- * request implementation.
- *
- * @param reason if not null contains CRL entry extension
- * that specifies revocation reason
+ * Constructs revocation info used by revocation request implementation.
+ *
+ * @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 c0949f66..d7198f6a 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
- * revocation information into database.
+ * 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 = 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.class.getSimpleName(), 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 39fdac87..c4a8ca96 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,12 @@ 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.
- *
+ * 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,19 +58,18 @@ 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));
}
/**
- * Maps LDAP attributes into object, and put the object
- * into 'parent'.
+ * 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 +77,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 +86,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 d14470a2..3269e61a 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,12 @@ 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.
- *
+ * 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 +57,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();
@@ -78,11 +75,10 @@ public class StringVectorMapper implements IDBAttrMapper {
}
/**
- * Maps LDAP attributes into object, and put the object
- * into 'parent'.
+ * 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 +100,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 963c2fdc..a2b2ea1c 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,13 @@ 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.
- *
+ * 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,19 +64,18 @@ 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()));
}
/**
- * Maps LDAP attributes into object, and put the object
- * into 'parent'.
+ * 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) {
@@ -90,14 +86,16 @@ public class X500NameMapper implements IDBAttrMapper {
attr.getStringValues().nextElement()));
} catch (IOException e) {
- /*LogDoc
- *
+ /*
+ * LogDoc
+ *
* @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 9acf05f2..63ec1e12 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,10 @@ 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
- * x509 certificate into database.
- *
- * @author thomask
+ * A class represents a mapper to serialize x509 certificate into database.
+ *
+ * @author thomask
* @version $Revision$, $Date$
*/
public class X509CertImplMapper implements IDBAttrMapper {
@@ -72,23 +69,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
@@ -119,7 +116,7 @@ public class X509CertImplMapper implements IDBAttrMapper {
if (critSet != null) {
for (Iterator<String> i = critSet.iterator(); i.hasNext();) {
- String oid = i.next();
+ String oid = i.next();
if (oid.equals("2.16.840.1.113730.1.1")) {
String extVal = getCertTypeExtensionInfo(cert);
@@ -145,19 +142,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 +200,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 +237,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,
@@ -249,8 +246,8 @@ public class X509CertImplMapper implements IDBAttrMapper {
// we retrieve it, DS returns it as
// userCertificate;binary. So I cannot do the
// following:
- // LDAPAttribute attr = attrs.getAttribute(
- // Schema.LDAP_ATTR_SIGNED_CERT);
+ // LDAPAttribute attr = attrs.getAttribute(
+ // Schema.LDAP_ATTR_SIGNED_CERT);
X509CertInfo certinfo = new X509CertInfo();
LDAPAttribute attr = attrs.getAttribute(
@@ -263,39 +260,39 @@ 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);
}
} catch (CertificateException e) {
- //throw new EDBException(
- // DBResources.FAILED_TO_DESERIALIZE_1, name);
+ // throw new EDBException(
+ // DBResources.FAILED_TO_DESERIALIZE_1, name);
parent.set(name, null);
} catch (Exception e) {
- //throw new EDBException(
- // DBResources.FAILED_TO_DESERIALIZE_1, name);
+ // 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 +310,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 +326,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 +334,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 +342,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 +350,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 +358,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 {