Search in sources :

Example 86 with CaMgmtException

use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.

the class CaManagerImpl method addPublisherToCa.

// method removePublisherFromCa
@Override
public void addPublisherToCa(String publisherName, String caName) throws CaMgmtException {
    publisherName = ParamUtil.requireNonBlank("publisherName", publisherName).toLowerCase();
    caName = ParamUtil.requireNonBlank("caName", caName).toLowerCase();
    asssertMasterMode();
    NameId ident = idNameMap.getPublisher(publisherName);
    if (ident == null) {
        String msg = concat("unknown publisher ", publisherName);
        LOG.warn(msg);
        throw new CaMgmtException(msg);
    }
    NameId caIdent = idNameMap.getCa(caName);
    if (caIdent == null) {
        String msg = concat("unknown CA ", caName);
        LOG.warn(msg);
        throw new CaMgmtException(msg);
    }
    Set<String> publisherNames = caHasPublishers.get(caName);
    if (publisherNames == null) {
        publisherNames = new HashSet<>();
        caHasPublishers.put(caName, publisherNames);
    } else {
        if (publisherNames.contains(publisherName)) {
            String msg = concat("publisher ", publisherName, " already associated with CA ", caName);
            LOG.warn(msg);
            throw new CaMgmtException(msg);
        }
    }
    IdentifiedX509CertPublisher publisher = publishers.get(publisherName);
    if (publisher == null) {
        throw new CaMgmtException(concat("publisher '", publisherName, "' is faulty"));
    }
    queryExecutor.addPublisherToCa(idNameMap.getPublisher(publisherName), caIdent);
    publisherNames.add(publisherName);
    caHasPublishers.get(caName).add(publisherName);
    publisher.caAdded(caInfos.get(caName).getCert());
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) NameId(org.xipki.ca.api.NameId)

Example 87 with CaMgmtException

use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.

the class CaManagerImpl method removeCertificate.

// method unrevokeCertificate
@Override
public void removeCertificate(String caName, BigInteger serialNumber) throws CaMgmtException {
    caName = ParamUtil.requireNonBlank("caName", caName).toLowerCase();
    ParamUtil.requireNonNull("serialNumber", serialNumber);
    asssertMasterMode();
    X509Ca ca = getX509Ca(caName);
    if (ca == null) {
        String msg = concat("unknown CA ", caName);
        LOG.warn(msg);
        throw new CaMgmtException(msg);
    }
    try {
        if (ca.removeCertificate(serialNumber, CaAuditConstants.MSGID_ca_mgmt) == null) {
            throw new CaMgmtException("could not remove certificate");
        }
    } catch (OperationException ex) {
        throw new CaMgmtException(ex.getMessage(), ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) OperationException(org.xipki.ca.api.OperationException)

Example 88 with CaMgmtException

use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.

the class CaManagerImpl method addCmpControl.

@Override
public void addCmpControl(CmpControlEntry dbEntry) throws CaMgmtException {
    ParamUtil.requireNonNull("dbEntry", dbEntry);
    asssertMasterMode();
    final String name = dbEntry.getName();
    if (cmpControlDbEntries.containsKey(name)) {
        throw new CaMgmtException(concat("CMP control named ", name, " exists"));
    }
    CmpControl cmpControl;
    try {
        cmpControl = new CmpControl(dbEntry);
    } catch (InvalidConfException ex) {
        LogUtil.error(LOG, ex, "could not add CMP control to certStore");
        throw new CaMgmtException(ex);
    }
    CmpControlEntry tmpDbEntry = cmpControl.getDbEntry();
    queryExecutor.addCmpControl(tmpDbEntry);
    cmpControls.put(name, cmpControl);
    cmpControlDbEntries.put(name, tmpDbEntry);
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) CmpControlEntry(org.xipki.ca.server.mgmt.api.CmpControlEntry) CmpControl(org.xipki.ca.server.mgmt.api.CmpControl) InvalidConfException(org.xipki.common.InvalidConfException)

Example 89 with CaMgmtException

use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.

the class CaManagerImpl method createCertprofile.

// method createX509CrlSigner
IdentifiedX509Certprofile createCertprofile(CertprofileEntry dbEntry) throws CaMgmtException {
    ParamUtil.requireNonNull("dbEntry", dbEntry);
    try {
        X509Certprofile profile = x509CertProfileFactoryRegister.newCertprofile(dbEntry.getType());
        IdentifiedX509Certprofile ret = new IdentifiedX509Certprofile(dbEntry, profile);
        ret.setEnvParameterResolver(envParameterResolver);
        ret.validate();
        return ret;
    } catch (ObjectCreationException | CertprofileException ex) {
        String msg = "could not initialize Certprofile " + dbEntry.getIdent();
        LogUtil.error(LOG, ex, msg);
        throw new CaMgmtException(msg, ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) X509Certprofile(org.xipki.ca.api.profile.x509.X509Certprofile) ObjectCreationException(org.xipki.common.ObjectCreationException) CertprofileException(org.xipki.ca.api.profile.CertprofileException)

Example 90 with CaMgmtException

use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.

the class CaManagerImpl method listCertificates.

@Override
public List<CertListInfo> listCertificates(String caName, X500Name subjectPattern, Date validFrom, Date validTo, CertListOrderBy orderBy, int numEntries) throws CaMgmtException {
    caName = ParamUtil.requireNonBlank("caName", caName).toLowerCase();
    ParamUtil.requireRange("numEntries", numEntries, 1, 1000);
    X509Ca ca = getX509Ca(caName);
    try {
        return ca.listCertificates(subjectPattern, validFrom, validTo, orderBy, numEntries);
    } catch (OperationException ex) {
        throw new CaMgmtException(ex.getMessage(), ex);
    }
}
Also used : CaMgmtException(org.xipki.ca.server.mgmt.api.CaMgmtException) OperationException(org.xipki.ca.api.OperationException)

Aggregations

CaMgmtException (org.xipki.ca.server.mgmt.api.CaMgmtException)157 PreparedStatement (java.sql.PreparedStatement)63 SQLException (java.sql.SQLException)63 CmdFailure (org.xipki.console.karaf.CmdFailure)52 NameId (org.xipki.ca.api.NameId)31 ResultSet (java.sql.ResultSet)24 OperationException (org.xipki.ca.api.OperationException)18 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16 InvalidConfException (org.xipki.common.InvalidConfException)11 DataAccessException (org.xipki.datasource.DataAccessException)11 CertificateEncodingException (java.security.cert.CertificateEncodingException)9 CaHasRequestorEntry (org.xipki.ca.server.mgmt.api.CaHasRequestorEntry)9 CertificateException (java.security.cert.CertificateException)8 ObjectCreationException (org.xipki.common.ObjectCreationException)8 X509Certificate (java.security.cert.X509Certificate)7 Date (java.util.Date)7 X509CaEntry (org.xipki.ca.server.mgmt.api.x509.X509CaEntry)7 IOException (java.io.IOException)6 Statement (java.sql.Statement)6 CaHasUserEntry (org.xipki.ca.server.mgmt.api.CaHasUserEntry)6