Search in sources :

Example 1 with CertPublisherException

use of org.xipki.ca.api.publisher.CertPublisherException in project xipki by xipki.

the class CaManagerImpl method createPublisher.

// method createCertprofile
IdentifiedX509CertPublisher createPublisher(PublisherEntry dbEntry) throws CaMgmtException {
    ParamUtil.requireNonNull("dbEntry", dbEntry);
    String type = dbEntry.getType();
    X509CertPublisher publisher;
    IdentifiedX509CertPublisher ret;
    try {
        if ("OCSP".equalsIgnoreCase(type)) {
            publisher = new OcspCertPublisher();
        } else {
            publisher = x509CertPublisherFactoryRegister.newPublisher(type);
        }
        ret = new IdentifiedX509CertPublisher(dbEntry, publisher);
        ret.initialize(securityFactory.getPasswordResolver(), datasources);
        return ret;
    } catch (ObjectCreationException | CertPublisherException | RuntimeException ex) {
        String msg = "invalid configuration for the publisher " + dbEntry.getIdent();
        LogUtil.error(LOG, ex, msg);
        throw new CaMgmtException(msg, ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) OcspCertPublisher(org.xipki.ca.server.impl.ocsp.OcspCertPublisher) X509CertPublisher(org.xipki.ca.api.publisher.x509.X509CertPublisher) ObjectCreationException(org.xipki.common.ObjectCreationException) CertPublisherException(org.xipki.ca.api.publisher.CertPublisherException)

Example 2 with CertPublisherException

use of org.xipki.ca.api.publisher.CertPublisherException in project xipki by xipki.

the class OcspCertPublisher method initialize.

@Override
public void initialize(String conf, PasswordResolver passwordResolver, Map<String, DataSourceWrapper> datasources) throws CertPublisherException {
    ParamUtil.requireNonNull("conf", conf);
    ParamUtil.requireNonEmpty("datasources", datasources);
    ConfPairs pairs = new ConfPairs(conf);
    String str = pairs.value("publish.goodcerts");
    this.publishsGoodCert = (str == null) ? true : Boolean.parseBoolean(str);
    str = pairs.value("asyn");
    this.asyn = (str == null) ? false : Boolean.parseBoolean(str);
    ConfPairs confPairs = new ConfPairs(conf);
    String datasourceName = confPairs.value("datasource");
    DataSourceWrapper datasource = null;
    if (datasourceName != null) {
        datasource = datasources.get(datasourceName);
    }
    if (datasource == null) {
        throw new CertPublisherException("no datasource named '" + datasourceName + "' is specified");
    }
    try {
        queryExecutor = new OcspStoreQueryExecutor(datasource, this.publishsGoodCert);
    } catch (NoSuchAlgorithmException | DataAccessException ex) {
        throw new CertPublisherException(ex.getMessage(), ex);
    }
}
Also used : ConfPairs(org.xipki.common.ConfPairs) CertPublisherException(org.xipki.ca.api.publisher.CertPublisherException) DataSourceWrapper(org.xipki.datasource.DataSourceWrapper) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) DataAccessException(org.xipki.datasource.DataAccessException)

Aggregations

CertPublisherException (org.xipki.ca.api.publisher.CertPublisherException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 X509CertPublisher (org.xipki.ca.api.publisher.x509.X509CertPublisher)1 OcspCertPublisher (org.xipki.ca.server.impl.ocsp.OcspCertPublisher)1 CaMgmtException (org.xipki.ca.server.mgmt.api.CaMgmtException)1 ConfPairs (org.xipki.common.ConfPairs)1 ObjectCreationException (org.xipki.common.ObjectCreationException)1 DataAccessException (org.xipki.datasource.DataAccessException)1 DataSourceWrapper (org.xipki.datasource.DataSourceWrapper)1