use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerQueryExecutor method changeEnvParam.
// method changeScep
void changeEnvParam(String name, String value) throws CaMgmtException {
ParamUtil.requireNonBlank("name", name);
ParamUtil.requireNonNull("value", value);
if (CaManagerImpl.ENV_EPOCH.equalsIgnoreCase(name)) {
throw new CaMgmtException(concat("environment ", name, " is reserved"));
}
final String sql = "UPDATE ENVIRONMENT SET VALUE2=? WHERE NAME=?";
PreparedStatement ps = null;
try {
ps = prepareStatement(sql);
ps.setString(1, getRealString(value));
ps.setString(2, name);
if (ps.executeUpdate() == 0) {
throw new CaMgmtException("could not change environment param " + name);
}
LOG.info("changed environment param '{}': {}", name, value);
} catch (SQLException ex) {
throw new CaMgmtException(datasource, sql, ex);
} finally {
datasource.releaseResources(ps, null);
}
}
use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerQueryExecutor method createCaHasRequestors.
// method createCaInfo
Set<CaHasRequestorEntry> createCaHasRequestors(NameId ca) throws CaMgmtException {
Map<Integer, String> idNameMap = getIdNameMap("REQUESTOR");
final String sql = "SELECT REQUESTOR_ID,RA,PERMISSION,PROFILES FROM CA_HAS_REQUESTOR WHERE CA_ID=?";
PreparedStatement stmt = null;
ResultSet rs = null;
try {
stmt = prepareStatement(sql);
stmt.setInt(1, ca.getId());
rs = stmt.executeQuery();
Set<CaHasRequestorEntry> ret = new HashSet<>();
while (rs.next()) {
int id = rs.getInt("REQUESTOR_ID");
String name = idNameMap.get(id);
boolean ra = rs.getBoolean("RA");
int permission = rs.getInt("PERMISSION");
String str = rs.getString("PROFILES");
List<String> list = StringUtil.splitByComma(str);
Set<String> profiles = (list == null) ? null : new HashSet<>(list);
CaHasRequestorEntry entry = new CaHasRequestorEntry(new NameId(id, name));
entry.setRa(ra);
entry.setPermission(permission);
entry.setProfiles(profiles);
ret.add(entry);
}
return ret;
} catch (SQLException ex) {
throw new CaMgmtException(datasource, sql, ex);
} finally {
datasource.releaseResources(stmt, rs);
}
}
use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerImpl method addResponder.
// method addCertprofile
@Override
public void addResponder(ResponderEntry dbEntry) throws CaMgmtException {
ParamUtil.requireNonNull("dbEntry", dbEntry);
asssertMasterMode();
String name = dbEntry.getName();
if (responderDbEntries.containsKey(name)) {
throw new CaMgmtException(concat("Responder named ", name, " exists"));
}
String conf = dbEntry.getConf();
if (conf != null) {
String newConf = canonicalizeSignerConf(dbEntry.getType(), conf, null, securityFactory);
if (!conf.equals(newConf)) {
dbEntry.setConf(newConf);
}
}
ResponderEntryWrapper responder = createResponder(dbEntry);
queryExecutor.addResponder(dbEntry);
responders.put(name, responder);
responderDbEntries.put(name, dbEntry);
}
use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerImpl method generateCrlOnDemand.
@Override
public X509CRL generateCrlOnDemand(String caName) throws CaMgmtException {
caName = ParamUtil.requireNonBlank("caName", caName).toLowerCase();
X509Ca ca = getX509Ca(caName);
try {
return ca.generateCrlOnDemand(CaAuditConstants.MSGID_ca_mgmt);
} 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 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);
}
}
Aggregations