use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerImpl method createX509CrlSigner.
// method createCmpResponder
X509CrlSignerEntryWrapper createX509CrlSigner(X509CrlSignerEntry dbEntry) throws CaMgmtException {
ParamUtil.requireNonNull("dbEntry", dbEntry);
X509CrlSignerEntryWrapper signer = new X509CrlSignerEntryWrapper();
try {
signer.setDbEntry(dbEntry);
} catch (InvalidConfException ex) {
throw new CaMgmtException(concat("InvalidConfException: ", ex.getMessage()));
}
try {
signer.initSigner(securityFactory);
} catch (XiSecurityException | OperationException | InvalidConfException ex) {
String message = "could not create CRL signer " + dbEntry.getName();
LogUtil.error(LOG, ex, message);
if (ex instanceof OperationException) {
throw new CaMgmtException(message + ": " + ((OperationException) ex).getErrorCode() + ", " + ex.getMessage());
} else {
throw new CaMgmtException(concat(message, ": ", ex.getMessage()));
}
}
return signer;
}
use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerImpl method initSceps.
// method initCmpControls
private void initSceps() throws CaMgmtException {
if (scepsInitialized) {
return;
}
sceps.clear();
scepDbEntries.clear();
List<String> names = queryExecutor.namesFromTable("SCEP");
for (String name : names) {
ScepEntry scepDb = queryExecutor.getScep(name, idNameMap);
if (scepDb == null) {
continue;
}
scepDbEntries.put(name, scepDb);
try {
ScepImpl scep = new ScepImpl(scepDb, this);
sceps.put(name, scep);
} catch (CaMgmtException ex) {
LogUtil.error(LOG, ex, concat("could not initialize SCEP entry ", name, ", ignore it"));
}
}
scepsInitialized = true;
}
use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerImpl method addScep.
// method getCurrentCrl
@Override
public void addScep(ScepEntry dbEntry) throws CaMgmtException {
ParamUtil.requireNonNull("dbEntry", dbEntry);
asssertMasterMode();
final String name = dbEntry.getName();
if (scepDbEntries.containsKey(name)) {
throw new CaMgmtException(concat("SCEP named ", name, " exists"));
}
String caName = dbEntry.getCaIdent().getName();
NameId caIdent = idNameMap.getCa(caName);
if (caIdent == null) {
String msg = concat("unknown CA ", caName);
LOG.warn(msg);
throw new CaMgmtException(msg);
}
dbEntry.getCaIdent().setId(caIdent.getId());
ScepImpl scep = new ScepImpl(dbEntry, this);
queryExecutor.addScep(dbEntry);
scepDbEntries.put(name, dbEntry);
sceps.put(name, scep);
}
use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerImpl method lockCa.
private void lockCa(boolean forceRelock) throws CaMgmtException {
SystemEvent lockInfo = queryExecutor.getSystemEvent(EVENT_LOCK);
if (lockInfo != null) {
String lockedBy = lockInfo.getOwner();
Date lockedAt = new Date(lockInfo.getEventTime() * 1000L);
if (!this.lockInstanceId.equals(lockedBy)) {
String msg = concat("could not lock CA, it has been locked by ", lockedBy, " since ", lockedAt.toString(), ". In general this indicates that another" + " CA software in active mode is accessing the database or the last shutdown of CA" + " software in active mode is abnormal.");
LOG.error(msg);
throw new CaMgmtException(msg);
}
if (forceRelock) {
LOG.info("CA has been locked by me since {}, re-lock it", lockedAt);
}
}
SystemEvent newLockInfo = new SystemEvent(EVENT_LOCK, lockInstanceId, System.currentTimeMillis() / 1000L);
queryExecutor.changeSystemEvent(newLockInfo);
caLockedByMe = true;
}
use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerImpl method getCrl.
// method generateCrlOnDemand
@Override
public X509CRL getCrl(String caName, BigInteger crlNumber) throws CaMgmtException {
caName = ParamUtil.requireNonBlank("caName", caName).toLowerCase();
ParamUtil.requireNonNull("crlNumber", crlNumber);
X509Ca ca = getX509Ca(caName);
try {
X509CRL crl = ca.getCrl(crlNumber);
if (crl == null) {
LOG.warn("found no CRL for CA {} and crlNumber {}", caName, crlNumber);
}
return crl;
} catch (OperationException ex) {
throw new CaMgmtException(ex.getMessage(), ex);
}
}
Aggregations