]> WPIA git - gigi.git/commitdiff
chg: add appName to filename for root certificate download
authorINOPIAE <m.maengel@inopiae.de>
Sun, 4 Feb 2018 09:38:40 +0000 (10:38 +0100)
committerINOPIAE <m.maengel@inopiae.de>
Sat, 10 Feb 2018 13:58:56 +0000 (14:58 +0100)
Change-Id: I6f6ebeb06b54c3a7c49b30d887daa188b1fa35c6

src/club/wpia/gigi/pages/RootCertPage.java

index 9d1d9c90eff4ec01f5f7ba1fc22adac68048a25e..25c024138093310a7173d0a4236bece2b3c321b6 100644 (file)
@@ -21,6 +21,7 @@ import club.wpia.gigi.localisation.Language;
 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 {
 
@@ -30,6 +31,8 @@ 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;
@@ -97,6 +100,7 @@ public class RootCertPage extends Page {
     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()));
@@ -106,6 +110,7 @@ public class RootCertPage extends Page {
             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());