import club.wpia.gigi.output.template.Outputable;
import club.wpia.gigi.util.HTMLEncoder;
import club.wpia.gigi.util.PEM;
+import club.wpia.gigi.util.ServerConstants;
public class RootCertPage extends Page {
private final OutputableCertificate rootP;
+ private final String appName = ServerConstants.getAppName().toLowerCase();
+
private class OutputableCertificate implements Outputable {
private final CACertificate target;
public boolean beforeTemplate(HttpServletRequest req, HttpServletResponse resp) throws IOException {
if (req.getParameter("pem") != null && root != null) {
resp.setContentType("application/x-x509-ca-cert");
+ resp.setHeader("Content-Disposition", "attachment; filename=\"" + appName + "_roots.crt\"");
ServletOutputStream out = resp.getOutputStream();
try {
out.println(PEM.encode("CERTIFICATE", root.getEncoded()));
return true;
} else if (req.getParameter("cer") != null && root != null) {
resp.setContentType("application/x-x509-ca-cert");
+ resp.setHeader("Content-Disposition", "attachment; filename=\"" + appName + "_roots.cer\"");
ServletOutputStream out = resp.getOutputStream();
try {
out.write(root.getEncoded());