public void update(HttpServletRequest request, HttpServletResponse response, Context context) throws IOException { IConfigStore config = CMS.getConfigStore(); String subsystemNick; try { subsystemNick = config.getString("preop.cert.subsystem.nickname"); } catch (EBaseException e1) { e1.printStackTrace(); throw new IOException("Failed to get subsystem certificate nickname"); } String url = HttpInput.getString(request, "urls"); URI caUri = null; String parsedURI = url.substring(url.lastIndexOf("http")); try { caUri = new URI(parsedURI); } catch (URISyntaxException e) { throw new IOException("Invalid URI " + parsedURI); } // TODO: get installer from session TPSInstaller installer = new TPSInstaller(); installer.configureCAConnector(caUri, subsystemNick); String host = caUri.getHost(); int port = caUri.getPort(); // Note - // list contains EE port. If admin port is different, it needs to // be obtained from security domain and used to get the cert chain /* int admin_port = ConfigurationUtils.getPortFromSecurityDomain(domainXML, host, port, "CA", "SecurePort", "SecureAdminPort"); */ try { ConfigurationUtils.importCertChain(host, port, "/ca/admin/ca/getCertChain", "ca"); } catch (CertificateException | SAXException | ParserConfigurationException | NotInitializedException | TokenException | EBaseException e) { e.printStackTrace(); throw new IOException("Failed to import certificate chain from CA"); } context.put("updateStatus", "success"); }