use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerImpl method createResponder.
// method shutdownPublisher
ResponderEntryWrapper createResponder(ResponderEntry dbEntry) throws CaMgmtException {
ParamUtil.requireNonNull("dbEntry", dbEntry);
ResponderEntryWrapper ret = new ResponderEntryWrapper();
ret.setDbEntry(dbEntry);
try {
ret.initSigner(securityFactory);
} catch (ObjectCreationException ex) {
final String message = "createCmpResponder";
LOG.debug(message, ex);
throw new CaMgmtException(ex.getMessage());
}
return ret;
}
use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerQueryExecutor method getScep.
// method removeScep
ScepEntry getScep(String name, CaIdNameMap idNameMap) throws CaMgmtException {
ParamUtil.requireNonBlank("name", name);
final String sql = sqls.sqlSelectScep;
ResultSet rs = null;
PreparedStatement ps = null;
try {
ps = prepareStatement(sql);
ps.setString(1, name);
rs = ps.executeQuery();
if (!rs.next()) {
throw new CaMgmtException("unknown SCEP " + name);
}
int caId = rs.getInt("CA_ID");
boolean active = rs.getBoolean("ACTIVE");
String profilesText = rs.getString("PROFILES");
String control = rs.getString("CONTROL");
String responderName = rs.getString("RESPONDER_NAME");
Set<String> profiles = StringUtil.splitByCommaAsSet(profilesText);
return new ScepEntry(name, idNameMap.getCa(caId), active, responderName, profiles, control);
} catch (SQLException ex) {
throw new CaMgmtException(datasource, sql, ex);
} catch (InvalidConfException ex) {
throw new CaMgmtException(ex);
} finally {
datasource.releaseResources(ps, rs);
}
}
use of org.xipki.ca.server.mgmt.api.CaMgmtException in project xipki by xipki.
the class CaManagerQueryExecutor method revokeCa.
// method removePublisherFromCa
void revokeCa(String caName, CertRevocationInfo revocationInfo) throws CaMgmtException {
ParamUtil.requireNonBlank("caName", caName);
ParamUtil.requireNonNull("revocationInfo", revocationInfo);
String sql = "UPDATE CA SET REV=?,RR=?,RT=?,RIT=? WHERE NAME=?";
PreparedStatement ps = null;
try {
if (revocationInfo.getInvalidityTime() == null) {
revocationInfo.setInvalidityTime(revocationInfo.getRevocationTime());
}
ps = prepareStatement(sql);
int idx = 1;
setBoolean(ps, idx++, true);
ps.setInt(idx++, revocationInfo.getReason().getCode());
ps.setLong(idx++, revocationInfo.getRevocationTime().getTime() / 1000);
ps.setLong(idx++, revocationInfo.getInvalidityTime().getTime() / 1000);
ps.setString(idx++, caName);
if (ps.executeUpdate() == 0) {
throw new CaMgmtException("could not revoke CA " + caName);
}
} 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 removeCaAlias.
// method removeCa
void removeCaAlias(String aliasName) throws CaMgmtException {
ParamUtil.requireNonBlank("aliasName", aliasName);
final String sql = "DELETE FROM CAALIAS WHERE NAME=?";
PreparedStatement ps = null;
try {
ps = prepareStatement(sql);
ps.setString(1, aliasName);
if (ps.executeUpdate() == 0) {
throw new CaMgmtException("could not remove CA Alias " + aliasName);
}
} 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 createPublisher.
// method getNamesFromTable
PublisherEntry createPublisher(String name) throws CaMgmtException {
final String sql = sqls.sqlSelectPublisher;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
stmt = prepareStatement(sql);
stmt.setString(1, name);
rs = stmt.executeQuery();
if (!rs.next()) {
throw new CaMgmtException("unkown Publisher " + name);
}
int id = rs.getInt("ID");
String type = rs.getString("TYPE");
String conf = rs.getString("CONF");
return new PublisherEntry(new NameId(id, name), type, conf);
} catch (SQLException ex) {
throw new CaMgmtException(datasource, sql, ex);
} finally {
datasource.releaseResources(stmt, rs);
}
}
Aggregations