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 cert store.- Since:
- 2.0.0
- Author:
- Lijun Liao (xipki)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCertStore.CertStatusstatic classCertStore.SerialWithId
-
Field Summary
Fields Modifier and Type Field Description protected org.xipki.datasource.DataSourceWrapperdatasource-
Fields inherited from class org.xipki.ca.server.db.CertStoreBase
caConfDatasource, dbSchemaVersion, keypairEncAlg, keypairEncAlgId, keypairEncKey, keypairEncKeyId, keypairEncProvider, maxX500nameLen, SQL_ADD_CERT, SQL_ADD_CRL, SQL_MAX_CRLNO, SQL_MAX_FULL_CRLNO, SQL_MAX_THISUPDAATE_CRL, SQL_REMOVE_CERT_FOR_ID, SQL_REVOKE_CERT, SQL_REVOKE_SUSPENDED_CERT
-
-
Constructor Summary
Constructors Constructor Description CertStore(org.xipki.datasource.DataSourceWrapper datasource, org.xipki.datasource.DataSourceWrapper caConfDatasource, UniqueIdGenerator idGenerator, org.xipki.password.PasswordResolver passwordResolver)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCa(org.xipki.ca.api.NameId ident, org.xipki.security.X509Cert caCert)booleanaddCert(org.xipki.ca.api.CertificateInfo certInfo, boolean saveKeypair)voidaddCertProfile(org.xipki.ca.api.NameId ident)voidaddCrl(org.xipki.ca.api.NameId ca, org.bouncycastle.cert.X509CRLHolder crl)voidaddRequestor(org.xipki.ca.api.NameId ident)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)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<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)voidremoveCa(String name)voidremoveCert(long id)voidremoveCertProfile(String name)voidremoveRequestor(String name)voidrevokeCa(String caName, org.xipki.security.CertRevocationInfo revocationInfo)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)voidunrevokeCa(String caName)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, org.xipki.datasource.DataSourceWrapper caConfDatasource, 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
-
removeCa
public void removeCa(String name) throws org.xipki.ca.api.mgmt.CaMgmtException
- Throws:
org.xipki.ca.api.mgmt.CaMgmtException
-
removeCertProfile
public void removeCertProfile(String name) throws org.xipki.ca.api.mgmt.CaMgmtException
- Throws:
org.xipki.ca.api.mgmt.CaMgmtException
-
removeRequestor
public void removeRequestor(String name) throws org.xipki.ca.api.mgmt.CaMgmtException
- Throws:
org.xipki.ca.api.mgmt.CaMgmtException
-
addCertProfile
public void addCertProfile(org.xipki.ca.api.NameId ident) throws org.xipki.ca.api.mgmt.CaMgmtException- Throws:
org.xipki.ca.api.mgmt.CaMgmtException
-
addRequestor
public void addRequestor(org.xipki.ca.api.NameId ident) throws org.xipki.ca.api.mgmt.CaMgmtException- Throws:
org.xipki.ca.api.mgmt.CaMgmtException
-
addCa
public void addCa(org.xipki.ca.api.NameId ident, org.xipki.security.X509Cert caCert) throws org.xipki.ca.api.mgmt.CaMgmtException- Throws:
org.xipki.ca.api.mgmt.CaMgmtException
-
revokeCa
public void revokeCa(String caName, org.xipki.security.CertRevocationInfo revocationInfo) throws org.xipki.ca.api.mgmt.CaMgmtException
- Throws:
org.xipki.ca.api.mgmt.CaMgmtException
-
unrevokeCa
public void unrevokeCa(String caName) throws org.xipki.ca.api.mgmt.CaMgmtException
- Throws:
org.xipki.ca.api.mgmt.CaMgmtException
-
addCert
public boolean addCert(org.xipki.ca.api.CertificateInfo certInfo, boolean saveKeypair)
-
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
-
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)
-
-