<%@ page import="org.jivesoftware.util.CertificateManager, org.jivesoftware.util.ParamUtils, org.jivesoftware.openfire.XMPPServer, org.jivesoftware.openfire.net.SSLConfig, java.io.ByteArrayInputStream, java.util.HashMap, java.util.Map" errorPage="error.jsp"%> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %> <%-- Created by IntelliJ IDEA. User: gato Date: Nov 7, 2006 Time: 10:03:19 AM To change this template use File | Settings | File Templates. --%> <% // Get parameters: boolean save = ParamUtils.getParameter(request, "save") != null; String privateKey = ParamUtils.getParameter(request, "private-key"); String certificate = ParamUtils.getParameter(request, "certificate"); Map errors = new HashMap(); if (save) { if (privateKey == null || "".equals(privateKey)) { errors.put("privateKey", "privateKey"); } if (certificate == null || "".equals(certificate)) { errors.put("certificate", "certificate"); } if (errors.isEmpty()) { try { // Create an alias for the signed certificate String domain = XMPPServer.getInstance().getServerInfo().getName(); int index = 1; String alias = domain + "_" + index; while (SSLConfig.getKeyStore().containsAlias(alias)) { index = index + 1; alias = domain + "_" + index; } // Import certificate CertificateManager.installCert(SSLConfig.getKeyStore(), SSLConfig.getTrustStore(), SSLConfig.getKeyPassword(), alias, new ByteArrayInputStream(privateKey.getBytes()), new ByteArrayInputStream(certificate.getBytes()), true, true); // Save keystore SSLConfig.saveStores(); response.sendRedirect("ssl-certificates.jsp?importsuccess=true"); return; } catch (Exception e) { e.printStackTrace(); errors.put("import", e); } } } %> <fmt:message key="ssl.import.certificate.title"/> <% if (errors.containsKey("privateKey")) { %>

<% } else if (errors.containsKey("certificate")) { %>

<% } else if (errors.containsKey("import")) { Exception e = (Exception)errors.get("import"); %>
<% if (e != null && e.getMessage() != null) { %> : <%= e.getMessage() %> <% } %>

<% } %>

">