Skip to content

Commit

Permalink
Replace CAAdminServlet.mCA with CAEngine.getCA()
Browse files Browse the repository at this point in the history
  • Loading branch information
edewata committed Jan 31, 2024
1 parent 647a086 commit 268e32c
Showing 1 changed file with 66 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public class CAAdminServlet extends AdminServlet {

private final static String INFO = "CAAdminServlet";

private CertificateAuthority mCA;
protected static final String PROP_ENABLED = "enabled";

/**
Expand All @@ -99,8 +98,6 @@ public CAAdminServlet() {
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
CAEngine engine = CAEngine.getInstance();
mCA = engine.getCA();
}

/**
Expand Down Expand Up @@ -274,8 +271,11 @@ private void getNotificationCompConfig(HttpServletRequest req, HttpServletRespon
private void getNotificationRevCompConfig(HttpServletRequest req, HttpServletResponse resp)
throws IOException, EBaseException {

CAConfig config = mCA.getConfigStore();
ConfigStore nc = config.getSubStore(CertificateAuthority.PROP_NOTIFY_SUBSTORE, ConfigStore.class);
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig caConfig = engineConfig.getCAConfig();

ConfigStore nc = caConfig.getSubStore(CertificateAuthority.PROP_NOTIFY_SUBSTORE, ConfigStore.class);
ConfigStore rc = nc.getSubStore(CertificateAuthority.PROP_CERT_REVOKED_SUBSTORE, ConfigStore.class);

getNotificationCompConfig(req, resp, rc);
Expand All @@ -284,8 +284,11 @@ private void getNotificationRevCompConfig(HttpServletRequest req, HttpServletRes
private void getNotificationReqCompConfig(HttpServletRequest req, HttpServletResponse resp)
throws IOException, EBaseException {

CAConfig config = mCA.getConfigStore();
ConfigStore nc = config.getSubStore(CertificateAuthority.PROP_NOTIFY_SUBSTORE, ConfigStore.class);
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig caConfig = engineConfig.getCAConfig();

ConfigStore nc = caConfig.getSubStore(CertificateAuthority.PROP_NOTIFY_SUBSTORE, ConfigStore.class);
ConfigStore rc = nc.getSubStore(CertificateAuthority.PROP_CERT_ISSUED_SUBSTORE, ConfigStore.class);

getNotificationCompConfig(req, resp, rc);
Expand All @@ -299,8 +302,10 @@ private void getNotificationRIQConfig(HttpServletRequest req, HttpServletRespons

NameValuePairs params = new NameValuePairs();

CAConfig config = mCA.getConfigStore();
ConfigStore nc = config.getSubStore(CertificateAuthority.PROP_NOTIFY_SUBSTORE, ConfigStore.class);
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig caConfig = engineConfig.getCAConfig();
ConfigStore nc = caConfig.getSubStore(CertificateAuthority.PROP_NOTIFY_SUBSTORE, ConfigStore.class);
ConfigStore riq = nc.getSubStore(CertificateAuthority.PROP_REQ_IN_Q_SUBSTORE, ConfigStore.class);

Enumeration<String> e = req.getParameterNames();
Expand Down Expand Up @@ -330,7 +335,7 @@ private void getNotificationRIQConfig(HttpServletRequest req, HttpServletRespons
private void setNotificationRIQConfig(HttpServletRequest req, HttpServletResponse resp)
throws IOException, EBaseException {

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig config = engineConfig.getCAConfig();
ConfigStore nc = config.getSubStore(CertificateAuthority.PROP_NOTIFY_SUBSTORE, ConfigStore.class);
Expand Down Expand Up @@ -435,7 +440,7 @@ private void setNotificationCompConfig(HttpServletRequest req, HttpServletRespon
private void setNotificationRevCompConfig(HttpServletRequest req, HttpServletResponse resp)
throws IOException, EBaseException {

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig config = engineConfig.getCAConfig();
ConfigStore nc = config.getSubStore(CertificateAuthority.PROP_NOTIFY_SUBSTORE, ConfigStore.class);
Expand All @@ -447,7 +452,7 @@ private void setNotificationRevCompConfig(HttpServletRequest req, HttpServletRes
private void setNotificationReqCompConfig(HttpServletRequest req, HttpServletResponse resp)
throws IOException, EBaseException {

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig config = engineConfig.getCAConfig();
ConfigStore nc = config.getSubStore(CertificateAuthority.PROP_NOTIFY_SUBSTORE, ConfigStore.class);
Expand All @@ -460,7 +465,7 @@ private void setNotificationReqCompConfig(HttpServletRequest req, HttpServletRes
private void listCRLIPsConfig(HttpServletResponse resp) throws IOException {
NameValuePairs params = new NameValuePairs();

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();

for (CRLIssuingPoint ip : engine.getCRLIssuingPoints()) {
if (ip != null) {
Expand All @@ -478,7 +483,7 @@ private void listCRLIPsConfig(HttpServletResponse resp) throws IOException {

private void getCRLIPsConfig(HttpServletRequest req, HttpServletResponse resp) throws IOException {

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
NameValuePairs params = new NameValuePairs();

String id = req.getParameter(Constants.RS_ID);
Expand Down Expand Up @@ -534,7 +539,8 @@ private void addCRLIPsConfig(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException, EBaseException {

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
CertificateAuthority ca = engine.getCA();
Auditor auditor = engine.getAuditor();

String auditMessage = null;
Expand Down Expand Up @@ -590,7 +596,7 @@ private void addCRLIPsConfig(HttpServletRequest req,
params.put(Constants.PR_ENABLED, Constants.TRUE);
}

CAConfig caConfig = mCA.getConfigStore();
CAConfig caConfig = ca.getConfigStore();
CRLConfig crlConfig = caConfig.getCRLConfig();
Enumeration<String> crlNames = crlConfig.getSubStoreNames().elements();

Expand All @@ -611,7 +617,7 @@ private void addCRLIPsConfig(HttpServletRequest req,
return;
}
}
if (!engine.addCRLIssuingPoint(mCA, crlConfig, ipId, enable, desc)) {
if (!engine.addCRLIssuingPoint(ca, crlConfig, ipId, enable, desc)) {
// store a message in the signed audit log file
auditMessage = CMS.getLogMessage(
AuditEvent.CONFIG_CRL_PROFILE,
Expand Down Expand Up @@ -694,7 +700,9 @@ private void setCRLIPsConfig(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException, EBaseException {

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig caConfig = engineConfig.getCAConfig();
Auditor auditor = engine.getAuditor();

String auditMessage = null;
Expand Down Expand Up @@ -750,7 +758,6 @@ private void setCRLIPsConfig(HttpServletRequest req,
params.put(Constants.PR_ENABLED, Constants.TRUE);
}

CAConfig caConfig = mCA.getConfigStore();
CRLConfig crlConfig = caConfig.getCRLConfig();
boolean done = false;
Enumeration<String> crlNames = crlConfig.getSubStoreNames().elements();
Expand Down Expand Up @@ -860,7 +867,8 @@ private void deleteCRLIPsConfig(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException, EBaseException {

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
CertificateAuthority ca = engine.getCA();
Auditor auditor = engine.getAuditor();

String auditMessage = null;
Expand All @@ -874,7 +882,7 @@ private void deleteCRLIPsConfig(HttpServletRequest req,
String id = req.getParameter(Constants.RS_ID);

if (id != null && id.length() > 0) {
CAConfig caConfig = mCA.getConfigStore();
CAConfig caConfig = ca.getConfigStore();
CRLConfig crlConfig = caConfig.getCRLConfig();
boolean done = false;
Enumeration<String> crlNames = crlConfig.getSubStoreNames().elements();
Expand All @@ -883,7 +891,7 @@ private void deleteCRLIPsConfig(HttpServletRequest req,
String name = crlNames.nextElement();

if (id.equals(name)) {
engine.deleteCRLIssuingPoint(mCA, crlConfig, id);
engine.deleteCRLIssuingPoint(ca, crlConfig, id);
done = true;
break;
}
Expand Down Expand Up @@ -955,7 +963,7 @@ private void deleteCRLIPsConfig(HttpServletRequest req,

private void getCRLExtsConfig(HttpServletRequest req, HttpServletResponse resp) throws IOException {

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();

NameValuePairs params = new NameValuePairs();

Expand Down Expand Up @@ -1007,7 +1015,9 @@ private void setCRLExtsConfig(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException, IOException, EBaseException {

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig caConfig = engineConfig.getCAConfig();
Auditor auditor = engine.getAuditor();

String auditMessage = null;
Expand All @@ -1027,7 +1037,6 @@ private void setCRLExtsConfig(HttpServletRequest req,
CRLIssuingPoint ip = engine.getCRLIssuingPoint(ipId);
CMSCRLExtensions crlExts = ip.getCRLExtensions();

CAConfig caConfig = mCA.getConfigStore();
CRLConfig crlConfig = caConfig.getCRLConfig();
CRLIssuingPointConfig ipConfig = crlConfig.getCRLIssuingPointConfig(ipId);
CRLExtensionsConfig crlExtsConfig = ipConfig.getExtensionsConfig();
Expand Down Expand Up @@ -1121,7 +1130,9 @@ private void listCRLExtsConfig(HttpServletRequest req, HttpServletResponse resp)
id = CertificateAuthority.PROP_MASTER_CRL;
}

CAConfig caConfig = mCA.getConfigStore();
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig caConfig = engineConfig.getCAConfig();
CRLConfig crlConfig = caConfig.getCRLConfig();
CRLIssuingPointConfig ipConfig = crlConfig.getCRLIssuingPointConfig(id);
CRLExtensionsConfig crlExtsConfig = ipConfig.getExtensionsConfig();
Expand Down Expand Up @@ -1172,7 +1183,7 @@ private NameValuePairs getExtendedPluginInfo(String implName) {
String ipId = null;
String name = null;

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
Enumeration<CRLIssuingPoint> ips = Collections.enumeration(engine.getCRLIssuingPoints());

if (ips.hasMoreElements()) {
Expand Down Expand Up @@ -1224,7 +1235,9 @@ private NameValuePairs getExtendedPluginInfo(String implName) {
private void setCRLConfig(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException, EBaseException {

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig caConfig = engineConfig.getCAConfig();
Auditor auditor = engine.getAuditor();

String auditMessage = null;
Expand All @@ -1244,7 +1257,6 @@ private void setCRLConfig(HttpServletRequest req, HttpServletResponse resp)
CRLIssuingPoint ip = engine.getCRLIssuingPoint(id);

//Save New Settings to the config file
CAConfig caConfig = mCA.getConfigStore();
CRLConfig crlConfig = caConfig.getCRLConfig();
CRLIssuingPointConfig ipConfig = crlConfig.getCRLIssuingPointConfig(id);

Expand Down Expand Up @@ -1333,7 +1345,10 @@ private void getCRLConfig(HttpServletRequest req, HttpServletResponse resp) thro
id.equals(Constants.RS_ID_CONFIG)) {
id = CertificateAuthority.PROP_MASTER_CRL;
}
CAConfig caConfig = mCA.getConfigStore();

CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig caConfig = engineConfig.getCAConfig();
CRLConfig crlConfig = caConfig.getCRLConfig();
CRLIssuingPointConfig ipConfig = crlConfig.getCRLIssuingPointConfig(id);

Expand All @@ -1359,7 +1374,9 @@ private void getCRLConfig(HttpServletRequest req, HttpServletResponse resp) thro

private void getConnectorConfig(HttpServletRequest req, HttpServletResponse resp)
throws IOException, EBaseException {
CAConfig caConfig = mCA.getConfigStore();
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig caConfig = engineConfig.getCAConfig();
ConnectorsConfig connectorsConfig = caConfig.getConnectorsConfig();
ConnectorConfig caConnectorConfig = null;

Expand Down Expand Up @@ -1392,7 +1409,9 @@ private void getConnectorConfig(HttpServletRequest req, HttpServletResponse resp
private void setConnectorConfig(HttpServletRequest req, HttpServletResponse resp)
throws IOException, EBaseException {

CAConfig caConfig = mCA.getConfigStore();
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig caConfig = engineConfig.getCAConfig();
ConnectorsConfig connectorsConfig = caConfig.getConnectorsConfig();
ConnectorConfig caConnectorConfig = null;

Expand Down Expand Up @@ -1487,12 +1506,13 @@ private void getGeneralConfig(HttpServletResponse resp) throws IOException, EBas
params.add(Constants.PR_EE_ENABLED, value);
*/

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig caConfig = engineConfig.getCAConfig();

DBSubsystem dbSubsystem = engine.getDBSubsystem();
CertificateRepository cr = engine.getCertificateRepository();

CAConfig caConfig = mCA.getConfigStore();

value = caConfig.getString(CertificateAuthority.PROP_ENABLE_PAST_CATIME, "false");
params.put(Constants.PR_VALIDITY, value);

Expand All @@ -1507,9 +1527,13 @@ private void getGeneralConfig(HttpServletResponse resp) throws IOException, EBas
}

private void getSigningAlgConfig(NameValuePairs params) {

CAEngine engine = (CAEngine) getCMSEngine();
CertificateAuthority ca = engine.getCA();

params.put(Constants.PR_DEFAULT_ALGORITHM,
mCA.getDefaultAlgorithm());
String[] algorithms = mCA.getCASigningAlgorithms();
ca.getDefaultAlgorithm());
String[] algorithms = ca.getCASigningAlgorithms();
StringBuffer algorStr = new StringBuffer();

for (int i = 0; i < algorithms.length; i++) {
Expand All @@ -1524,12 +1548,12 @@ private void getSigningAlgConfig(NameValuePairs params) {
}

private void getSerialConfig(NameValuePairs params) {
CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
params.put(Constants.PR_SERIAL, engine.getStartSerial());
}

private void getMaxSerialConfig(NameValuePairs params) {
CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
params.put(Constants.PR_MAXSERIAL, engine.getMaxSerial());
}

Expand All @@ -1541,7 +1565,7 @@ private void setGeneralConfig(HttpServletRequest req, HttpServletResponse resp)
SubsystemRegistry.getInstance().get("eeGateway");
*/

CAEngine engine = CAEngine.getInstance();
CAEngine engine = (CAEngine) getCMSEngine();
CAEngineConfig engineConfig = engine.getConfig();
CAConfig caConfig = engineConfig.getCAConfig();

Expand Down Expand Up @@ -1574,7 +1598,8 @@ private void setGeneralConfig(HttpServletRequest req, HttpServletResponse resp)
caConfig.putString(CertificateAuthority.PROP_ENABLE_PAST_CATIME, value);

} else if (key.equals(Constants.PR_DEFAULT_ALGORITHM)) {
mCA.setDefaultAlgorithm(value);
CertificateAuthority ca = engine.getCA();
ca.setDefaultAlgorithm(value);

} else if (key.equals(Constants.PR_SERIAL)) {
engine.setStartSerial(value);
Expand Down

0 comments on commit 268e32c

Please sign in to comment.