Package org.xipki.ca.server.db
Class CertStore
- java.lang.Object
-
- org.xipki.ca.server.db.CertStoreBase
-
- org.xipki.ca.server.db.CertStore
-
public class CertStore extends CertStoreBase
CA database store.- Since:
- 2.0.0
- Author:
- Lijun Liao (xipki)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCertStore.CertStatusstatic classCertStore.SerialWithIdstatic classCertStore.SystemEvent
-
Field Summary
Fields Modifier and Type Field Description protected org.xipki.datasource.DataSourceWrapperdatasource-
Fields inherited from class org.xipki.ca.server.db.CertStoreBase
dbSchemaVersion, keypairEncAlg, keypairEncAlgId, keypairEncKey, keypairEncKeyId, keypairEncProvider, maxX500nameLen, SQL_ADD_CERT, SQL_ADD_CRL, SQL_INSERT_PUBLISHQUEUE, SQL_MAX_CRLNO, SQL_MAX_FULL_CRLNO, SQL_MAX_THISUPDAATE_CRL, SQL_REMOVE_CERT_FOR_ID, SQL_REMOVE_PUBLISHQUEUE, SQL_REVOKE_CERT, SQL_REVOKE_SUSPENDED_CERT
-
-
Constructor Summary
Constructors Constructor Description CertStore(org.xipki.datasource.DataSourceWrapper datasource, UniqueIdGenerator idGenerator, org.xipki.password.PasswordResolver passwordResolver)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddCert(org.xipki.ca.api.CertificateInfo certInfo, boolean saveKeypair)voidaddCrl(org.xipki.ca.api.NameId ca, org.bouncycastle.cert.X509CRLHolder crl)voidaddToPublishQueue(org.xipki.ca.api.NameId publisher, long certId, org.xipki.ca.api.NameId ca)protected PreparedStatementbuildPrepStmt(String sql, org.xipki.ca.server.db.QueryExecutor.SqlColumn2... columns)protected StringbuildSelectFirstSql(String coreSql)protected StringbuildSelectFirstSql(String orderBy, String coreSql)intcleanupCrls(org.xipki.ca.api.NameId ca, int numCrls)voidclearPublishQueue(org.xipki.ca.api.NameId ca, org.xipki.ca.api.NameId publisher)protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn2col2Bool(Boolean value)protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn2col2Int(Integer value)protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn2col2Long(Long value)protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn2col2Str(String value)protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn2col2Timestamp(Timestamp value)protected static org.xipki.ca.server.db.QueryExecutor.SqlColumncolBool(String name, Boolean value)protected static org.xipki.ca.server.db.QueryExecutor.SqlColumncolInt(String name, Integer value)protected static org.xipki.ca.server.db.QueryExecutor.SqlColumncolLong(String name, Long value)protected static org.xipki.ca.server.db.QueryExecutor.SqlColumncolStr(String name, String value)protected static org.xipki.ca.server.db.QueryExecutor.SqlColumncolStr(String name, String value, boolean sensitive, boolean signerConf)protected org.xipki.ca.server.db.ResultRowexecQuery1PrepStmt(String sql, org.xipki.ca.server.db.QueryExecutor.SqlColumn2... params)protected List<org.xipki.ca.server.db.ResultRow>execQueryPrepStmt(String sql, org.xipki.ca.server.db.QueryExecutor.SqlColumn2... params)protected List<org.xipki.ca.server.db.ResultRow>execQueryStmt(String sql)protected intexecUpdatePrepStmt(String sql, org.xipki.ca.server.db.QueryExecutor.SqlColumn2... params)protected intexecUpdateStmt(String sql)org.xipki.security.X509CertgetCert(org.bouncycastle.asn1.x500.X500Name subjectName, String transactionId)Get certificate for given subject and transactionId.org.xipki.ca.api.CertificateInfogetCertForId(org.xipki.ca.api.NameId ca, org.xipki.security.X509Cert caCert, long certId, CaIdNameMap idNameMap)longgetCertId(org.xipki.ca.api.NameId ca, BigInteger serial)org.xipki.ca.api.CertificateInfogetCertInfo(org.xipki.ca.api.NameId ca, org.xipki.security.X509Cert caCert, BigInteger serial, CaIdNameMap idNameMap)List<CertRevInfoWithSerial>getCertsForDeltaCrl(org.xipki.ca.api.NameId ca, BigInteger baseCrlNumber, Instant notExpiredAt)CertStore.CertStatusgetCertStatusForSubject(org.xipki.ca.api.NameId ca, org.bouncycastle.asn1.x500.X500Name subject)org.xipki.ca.api.mgmt.CertWithRevocationInfogetCertWithRevocationInfo(int caId, BigInteger serial, CaIdNameMap idNameMap)org.xipki.ca.api.mgmt.CertWithRevocationInfogetCertWithRevocationInfo(long certId, CaIdNameMap idNameMap)org.xipki.ca.api.mgmt.CertWithRevocationInfogetCertWithRevocationInfoBySubject(int caId, org.bouncycastle.asn1.x500.X500Name subject, byte[] san, CaIdNameMap idNameMap)longgetCountOfCerts(long notBeforeSince)longgetCountOfCerts(org.xipki.ca.api.NameId ca, boolean onlyRevoked)byte[]getEncodedCrl(org.xipki.ca.api.NameId ca, BigInteger crlNumber)List<CertStore.SerialWithId>getExpiredUnrevokedSerialNumbers(org.xipki.ca.api.NameId ca, long expiredAt, int numEntries)longgetMaxCrlNumber(org.xipki.ca.api.NameId ca)longgetMaxFullCrlNumber(org.xipki.ca.api.NameId ca)List<Long>getPublishQueueEntries(org.xipki.ca.api.NameId ca, org.xipki.ca.api.NameId publisher, int numEntries)List<CertRevInfoWithSerial>getRevokedCerts(org.xipki.ca.api.NameId ca, Instant notExpiredAt, long startId, int numEntries)List<CertStore.SerialWithId>getSerialNumbers(org.xipki.ca.api.NameId ca, long startId, int numEntries, boolean onlyRevoked)List<CertStore.SerialWithId>getSuspendedCertSerials(org.xipki.ca.api.NameId ca, Instant latestLastUpdate, int numEntries)longgetThisUpdateOfCurrentCrl(org.xipki.ca.api.NameId ca, boolean deltaCrl)booleanisHealthy()List<org.xipki.ca.api.mgmt.CertListInfo>listCerts(org.xipki.ca.api.NameId ca, org.bouncycastle.asn1.x500.X500Name subjectPattern, Instant validFrom, Instant validTo, org.xipki.ca.api.mgmt.CertListOrderBy orderBy, int numEntries)protected voidnotNulls(Object param1, String name1, Object param2, String name2)protected voidnotNulls(Object param1, String name1, Object param2, String name2, Object param3, String name3)protected voidnotNulls(Object param1, String name1, Object param2, String name2, Object param3, String name3, Object param4, String name4)voidremoveCert(long id)voidremoveFromPublishQueue(org.xipki.ca.api.NameId publisher, long certId)org.xipki.ca.api.mgmt.CertWithRevocationInforevokeCert(org.xipki.ca.api.NameId ca, BigInteger serialNumber, org.xipki.security.CertRevocationInfo revInfo, boolean force, CaIdNameMap idNameMap)org.xipki.ca.api.mgmt.CertWithRevocationInforevokeSuspendedCert(org.xipki.ca.api.NameId ca, CertStore.SerialWithId serialNumber, org.xipki.security.CrlReason reason, CaIdNameMap idNameMap)org.xipki.ca.api.CertWithDbIdunsuspendCert(org.xipki.ca.api.NameId ca, BigInteger serialNumber, boolean force, CaIdNameMap idNamMap)-
Methods inherited from class org.xipki.ca.server.db.CertStoreBase
buildArraySql, buildCertRevInfo, buildPrepStmt0, execQuery1PrepStmt0, execQueryLongPrepStmt, execQueryPrepStmt0, execUpdatePrepStmt0, execUpdateStmt0, getMax, parseCert, prepareStatement, updateDbInfo
-
-
-
-
Constructor Detail
-
CertStore
public CertStore(org.xipki.datasource.DataSourceWrapper datasource, UniqueIdGenerator idGenerator, org.xipki.password.PasswordResolver passwordResolver) throws org.xipki.datasource.DataAccessException, org.xipki.ca.api.mgmt.CaMgmtException- Throws:
org.xipki.datasource.DataAccessExceptionorg.xipki.ca.api.mgmt.CaMgmtException
-
-
Method Detail
-
addCert
public boolean addCert(org.xipki.ca.api.CertificateInfo certInfo, boolean saveKeypair)
-
addToPublishQueue
public void addToPublishQueue(org.xipki.ca.api.NameId publisher, long certId, org.xipki.ca.api.NameId ca) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
removeFromPublishQueue
public void removeFromPublishQueue(org.xipki.ca.api.NameId publisher, long certId) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
clearPublishQueue
public void clearPublishQueue(org.xipki.ca.api.NameId ca, org.xipki.ca.api.NameId publisher) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
getMaxFullCrlNumber
public long getMaxFullCrlNumber(org.xipki.ca.api.NameId ca) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
getMaxCrlNumber
public long getMaxCrlNumber(org.xipki.ca.api.NameId ca) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
getThisUpdateOfCurrentCrl
public long getThisUpdateOfCurrentCrl(org.xipki.ca.api.NameId ca, boolean deltaCrl) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
addCrl
public void addCrl(org.xipki.ca.api.NameId ca, org.bouncycastle.cert.X509CRLHolder crl) throws org.xipki.util.exception.OperationException, CRLException- Throws:
org.xipki.util.exception.OperationExceptionCRLException
-
revokeCert
public org.xipki.ca.api.mgmt.CertWithRevocationInfo revokeCert(org.xipki.ca.api.NameId ca, BigInteger serialNumber, org.xipki.security.CertRevocationInfo revInfo, boolean force, CaIdNameMap idNameMap) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
revokeSuspendedCert
public org.xipki.ca.api.mgmt.CertWithRevocationInfo revokeSuspendedCert(org.xipki.ca.api.NameId ca, CertStore.SerialWithId serialNumber, org.xipki.security.CrlReason reason, CaIdNameMap idNameMap) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
unsuspendCert
public org.xipki.ca.api.CertWithDbId unsuspendCert(org.xipki.ca.api.NameId ca, BigInteger serialNumber, boolean force, CaIdNameMap idNamMap) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
removeCert
public void removeCert(long id) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
getPublishQueueEntries
public List<Long> getPublishQueueEntries(org.xipki.ca.api.NameId ca, org.xipki.ca.api.NameId publisher, int numEntries) throws org.xipki.util.exception.OperationException
- Throws:
org.xipki.util.exception.OperationException
-
getCountOfCerts
public long getCountOfCerts(org.xipki.ca.api.NameId ca, boolean onlyRevoked) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
getCountOfCerts
public long getCountOfCerts(long notBeforeSince) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
getSerialNumbers
public List<CertStore.SerialWithId> getSerialNumbers(org.xipki.ca.api.NameId ca, long startId, int numEntries, boolean onlyRevoked) throws org.xipki.util.exception.OperationException
- Throws:
org.xipki.util.exception.OperationException
-
getExpiredUnrevokedSerialNumbers
public List<CertStore.SerialWithId> getExpiredUnrevokedSerialNumbers(org.xipki.ca.api.NameId ca, long expiredAt, int numEntries) throws org.xipki.util.exception.OperationException
- Throws:
org.xipki.util.exception.OperationException
-
getSuspendedCertSerials
public List<CertStore.SerialWithId> getSuspendedCertSerials(org.xipki.ca.api.NameId ca, Instant latestLastUpdate, int numEntries) throws org.xipki.util.exception.OperationException
- Throws:
org.xipki.util.exception.OperationException
-
getEncodedCrl
public byte[] getEncodedCrl(org.xipki.ca.api.NameId ca, BigInteger crlNumber) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
cleanupCrls
public int cleanupCrls(org.xipki.ca.api.NameId ca, int numCrls) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
getCertForId
public org.xipki.ca.api.CertificateInfo getCertForId(org.xipki.ca.api.NameId ca, org.xipki.security.X509Cert caCert, long certId, CaIdNameMap idNameMap) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
getCertWithRevocationInfo
public org.xipki.ca.api.mgmt.CertWithRevocationInfo getCertWithRevocationInfo(long certId, CaIdNameMap idNameMap) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
getCertWithRevocationInfo
public org.xipki.ca.api.mgmt.CertWithRevocationInfo getCertWithRevocationInfo(int caId, BigInteger serial, CaIdNameMap idNameMap) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
getCertWithRevocationInfoBySubject
public org.xipki.ca.api.mgmt.CertWithRevocationInfo getCertWithRevocationInfoBySubject(int caId, org.bouncycastle.asn1.x500.X500Name subject, byte[] san, CaIdNameMap idNameMap) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
getCertId
public long getCertId(org.xipki.ca.api.NameId ca, BigInteger serial) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
getCertInfo
public org.xipki.ca.api.CertificateInfo getCertInfo(org.xipki.ca.api.NameId ca, org.xipki.security.X509Cert caCert, BigInteger serial, CaIdNameMap idNameMap) throws org.xipki.util.exception.OperationException- Throws:
org.xipki.util.exception.OperationException
-
getCert
public org.xipki.security.X509Cert getCert(org.bouncycastle.asn1.x500.X500Name subjectName, String transactionId) throws org.xipki.util.exception.OperationExceptionGet certificate for given subject and transactionId.- Parameters:
subjectName- Subject of Certificate or requested Subject.transactionId- the transactionId- Returns:
- certificate for given subject and transactionId.
- Throws:
org.xipki.util.exception.OperationException- If error occurs.
-
listCerts
public List<org.xipki.ca.api.mgmt.CertListInfo> listCerts(org.xipki.ca.api.NameId ca, org.bouncycastle.asn1.x500.X500Name subjectPattern, Instant validFrom, Instant validTo, org.xipki.ca.api.mgmt.CertListOrderBy orderBy, int numEntries) throws org.xipki.util.exception.OperationException
- Throws:
org.xipki.util.exception.OperationException
-
getRevokedCerts
public List<CertRevInfoWithSerial> getRevokedCerts(org.xipki.ca.api.NameId ca, Instant notExpiredAt, long startId, int numEntries) throws org.xipki.util.exception.OperationException
- Throws:
org.xipki.util.exception.OperationException
-
getCertsForDeltaCrl
public List<CertRevInfoWithSerial> getCertsForDeltaCrl(org.xipki.ca.api.NameId ca, BigInteger baseCrlNumber, Instant notExpiredAt) throws org.xipki.util.exception.OperationException
- Throws:
org.xipki.util.exception.OperationException
-
getCertStatusForSubject
public CertStore.CertStatus getCertStatusForSubject(org.xipki.ca.api.NameId ca, org.bouncycastle.asn1.x500.X500Name subject) throws org.xipki.util.exception.OperationException
- Throws:
org.xipki.util.exception.OperationException
-
isHealthy
public boolean isHealthy()
-
colBool
protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn colBool(String name, Boolean value)
-
colInt
protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn colInt(String name, Integer value)
-
colLong
protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn colLong(String name, Long value)
-
colStr
protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn colStr(String name, String value)
-
colStr
protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn colStr(String name, String value, boolean sensitive, boolean signerConf)
-
col2Bool
protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn2 col2Bool(Boolean value)
-
col2Int
protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn2 col2Int(Integer value)
-
col2Long
protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn2 col2Long(Long value)
-
col2Str
protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn2 col2Str(String value)
-
col2Timestamp
protected static org.xipki.ca.server.db.QueryExecutor.SqlColumn2 col2Timestamp(Timestamp value)
-
execUpdateStmt
protected int execUpdateStmt(String sql) throws org.xipki.datasource.DataAccessException
- Throws:
org.xipki.datasource.DataAccessException
-
execUpdatePrepStmt
protected int execUpdatePrepStmt(String sql, org.xipki.ca.server.db.QueryExecutor.SqlColumn2... params) throws org.xipki.datasource.DataAccessException
- Throws:
org.xipki.datasource.DataAccessException
-
execQueryStmt
protected List<org.xipki.ca.server.db.ResultRow> execQueryStmt(String sql) throws org.xipki.datasource.DataAccessException
- Throws:
org.xipki.datasource.DataAccessException
-
execQuery1PrepStmt
protected org.xipki.ca.server.db.ResultRow execQuery1PrepStmt(String sql, org.xipki.ca.server.db.QueryExecutor.SqlColumn2... params) throws org.xipki.datasource.DataAccessException
- Throws:
org.xipki.datasource.DataAccessException
-
execQueryPrepStmt
protected List<org.xipki.ca.server.db.ResultRow> execQueryPrepStmt(String sql, org.xipki.ca.server.db.QueryExecutor.SqlColumn2... params) throws org.xipki.datasource.DataAccessException
- Throws:
org.xipki.datasource.DataAccessException
-
buildPrepStmt
protected PreparedStatement buildPrepStmt(String sql, org.xipki.ca.server.db.QueryExecutor.SqlColumn2... columns) throws org.xipki.datasource.DataAccessException
- Throws:
org.xipki.datasource.DataAccessException
-
notNulls
protected void notNulls(Object param1, String name1, Object param2, String name2, Object param3, String name3)
-
-