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());
}
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);
}
}
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);
}
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);
}
}
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);
}
}
Aggregations