Class DbCaConfStore

  • All Implemented Interfaces:
    CaConfStore

    public class DbCaConfStore
    extends Object
    implements CaConfStore
    Execute the database queries to manage CA system.
    Since:
    2.0.0
    Author:
    Lijun Liao (xipki)
    • Field Detail

      • datasource

        protected final org.xipki.datasource.DataSourceWrapper datasource
    • Constructor Detail

      • DbCaConfStore

        public DbCaConfStore​(org.xipki.datasource.DataSourceWrapper datasource)
                      throws org.xipki.ca.api.mgmt.CaMgmtException
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
    • Method Detail

      • getSystemEvent

        public SystemEvent getSystemEvent​(String eventName)
                                   throws org.xipki.ca.api.mgmt.CaMgmtException
        Retrieve the system event.
        Specified by:
        getSystemEvent in interface CaConfStore
        Parameters:
        eventName - Event name
        Returns:
        the System event, may be null.
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException - If error occurs.
      • changeSystemEvent

        public void changeSystemEvent​(SystemEvent systemEvent)
                               throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        changeSystemEvent in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • createCaAliases

        public Map<String,​Integer> createCaAliases()
                                                  throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        createCaAliases in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • createCertprofile

        public org.xipki.ca.api.mgmt.entry.CertprofileEntry createCertprofile​(String name)
                                                                       throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        createCertprofile in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • createPublisher

        public org.xipki.ca.api.mgmt.entry.PublisherEntry createPublisher​(String name)
                                                                   throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        createPublisher in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • getRequestorId

        public Integer getRequestorId​(String requestorName)
                               throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        getRequestorId in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • createRequestor

        public org.xipki.ca.api.mgmt.entry.RequestorEntry createRequestor​(String name)
                                                                   throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        createRequestor in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • createSigner

        public org.xipki.ca.api.mgmt.entry.SignerEntry createSigner​(String name)
                                                             throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        createSigner in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • createKeypairGen

        public org.xipki.ca.api.mgmt.entry.KeypairGenEntry createKeypairGen​(String name)
                                                                     throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        createKeypairGen in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • createCaInfo

        public CaInfo createCaInfo​(String name,
                                   CertStore certstore)
                            throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        createCaInfo in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • createCaHasRequestors

        public Set<org.xipki.ca.api.mgmt.entry.CaHasRequestorEntry> createCaHasRequestors​(org.xipki.ca.api.NameId ca)
                                                                                   throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        createCaHasRequestors in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • createCaHasProfiles

        public Set<CaProfileIdAliases> createCaHasProfiles​(org.xipki.ca.api.NameId ca)
                                                    throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        createCaHasProfiles in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • createCaHasPublishers

        public Set<Integer> createCaHasPublishers​(org.xipki.ca.api.NameId ca)
                                           throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        createCaHasPublishers in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • addCa

        public void addCa​(org.xipki.ca.api.mgmt.entry.CaEntry caEntry)
                   throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        addCa in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • addCaAlias

        public void addCaAlias​(String aliasName,
                               org.xipki.ca.api.NameId ca)
                        throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        addCaAlias in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • addCertprofile

        public void addCertprofile​(org.xipki.ca.api.mgmt.entry.CertprofileEntry dbEntry)
                            throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        addCertprofile in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • addCertprofileToCa

        public void addCertprofileToCa​(org.xipki.ca.api.NameId profile,
                                       org.xipki.ca.api.NameId ca,
                                       List<String> aliases)
                                throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        addCertprofileToCa in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • addPublisherToCa

        public void addPublisherToCa​(org.xipki.ca.api.NameId publisher,
                                     org.xipki.ca.api.NameId ca)
                              throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        addPublisherToCa in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • addRequestor

        public void addRequestor​(org.xipki.ca.api.mgmt.entry.RequestorEntry dbEntry)
                          throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        addRequestor in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • addEmbeddedRequestor

        public org.xipki.ca.api.NameId addEmbeddedRequestor​(String requestorName)
                                                     throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        addEmbeddedRequestor in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • addRequestorToCa

        public void addRequestorToCa​(org.xipki.ca.api.mgmt.entry.CaHasRequestorEntry requestor,
                                     org.xipki.ca.api.NameId ca)
                              throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        addRequestorToCa in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • addPublisher

        public void addPublisher​(org.xipki.ca.api.mgmt.entry.PublisherEntry dbEntry)
                          throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        addPublisher in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • changeCa

        public void changeCa​(org.xipki.ca.api.mgmt.entry.ChangeCaEntry changeCaEntry,
                             org.xipki.ca.api.mgmt.entry.CaConfColumn currentCaConfColumn,
                             org.xipki.security.SecurityFactory securityFactory)
                      throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        changeCa in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • commitNextCrlNoIfLess

        public void commitNextCrlNoIfLess​(org.xipki.ca.api.NameId ca,
                                          long nextCrlNo)
                                   throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        commitNextCrlNoIfLess in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • changeSigner

        public org.xipki.ca.api.mgmt.entry.SignerEntry changeSigner​(String name,
                                                                    String type,
                                                                    String conf,
                                                                    String base64Cert,
                                                                    CaManagerImpl signerManager)
                                                             throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        changeSigner in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • removeCaAlias

        public void removeCaAlias​(String aliasName)
                           throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        removeCaAlias in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • removeCertprofileFromCa

        public void removeCertprofileFromCa​(String profileName,
                                            String caName)
                                     throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        removeCertprofileFromCa in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • removeRequestorFromCa

        public void removeRequestorFromCa​(String requestorName,
                                          String caName)
                                   throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        removeRequestorFromCa in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • removePublisherFromCa

        public void removePublisherFromCa​(String publisherName,
                                          String caName)
                                   throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        removePublisherFromCa in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • removeDbSchema

        public void removeDbSchema​(String name)
                            throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        removeDbSchema in interface CaConfStore
        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
        Specified by:
        revokeCa in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • addKeypairGen

        public void addKeypairGen​(org.xipki.ca.api.mgmt.entry.KeypairGenEntry dbEntry)
                           throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        addKeypairGen in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • addSigner

        public void addSigner​(org.xipki.ca.api.mgmt.entry.SignerEntry dbEntry)
                       throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        addSigner in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • unlockCa

        public void unlockCa()
                      throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        unlockCa in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • unrevokeCa

        public void unrevokeCa​(String caName)
                        throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        unrevokeCa in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • addDbSchema

        public void addDbSchema​(String name,
                                String value)
                         throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        addDbSchema in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • changeDbSchema

        public void changeDbSchema​(String name,
                                   String value)
                            throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        changeDbSchema in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • getDbSchemas

        public Map<String,​String> getDbSchemas()
                                              throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        getDbSchemas in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • getCaNames

        public List<String> getCaNames()
                                throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        getCaNames in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • deleteCa

        public boolean deleteCa​(String name)
                         throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        deleteCa in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • getKeyPairGenNames

        public List<String> getKeyPairGenNames()
                                        throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        getKeyPairGenNames in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • deleteKeyPairGen

        public boolean deleteKeyPairGen​(String name)
                                 throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        deleteKeyPairGen in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • getProfileNames

        public List<String> getProfileNames()
                                     throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        getProfileNames in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • deleteProfile

        public boolean deleteProfile​(String name)
                              throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        deleteProfile in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • getPublisherNames

        public List<String> getPublisherNames()
                                       throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        getPublisherNames in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • deletePublisher

        public boolean deletePublisher​(String name)
                                throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        deletePublisher in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • getRequestorNames

        public List<String> getRequestorNames()
                                       throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        getRequestorNames in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • deleteRequestor

        public boolean deleteRequestor​(String name)
                                throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        deleteRequestor in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • getSignerNames

        public List<String> getSignerNames()
                                    throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        getSignerNames in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • deleteSigner

        public boolean deleteSigner​(String name)
                             throws org.xipki.ca.api.mgmt.CaMgmtException
        Specified by:
        deleteSigner in interface CaConfStore
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • getMaxX500nameLen

        public int getMaxX500nameLen()
      • namesFromTable

        public List<String> namesFromTable​(String table)
                                    throws org.xipki.ca.api.mgmt.CaMgmtException
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • deleteRowWithName

        public boolean deleteRowWithName​(String name,
                                         String table)
                                  throws org.xipki.ca.api.mgmt.CaMgmtException
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • buildSelectFirstSql

        protected String buildSelectFirstSql​(String coreSql)
      • buildSelectFirstSql

        protected String buildSelectFirstSql​(String orderBy,
                                             String coreSql)
      • 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