]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/output/template/Form.java
UPD: extract certificate requests out of form (preparing for API)
[gigi.git] / src / org / cacert / gigi / output / template / Form.java
index f469c21c68bf53080d4f40863cb1e67a85dedc36..f330fe865a9e36e42ff874528338db347cdb1ea9 100644 (file)
@@ -17,13 +17,19 @@ public abstract class Form implements Outputable {
 
     public static final String CSRF_FIELD = "csrf";
 
-    private String csrf;
+    private final String csrf;
+
+    private final String action;
 
     public Form(HttpServletRequest hsr) {
+        this(hsr, null);
+    }
+
+    public Form(HttpServletRequest hsr, String action) {
         csrf = RandomToken.generateToken(32);
+        this.action = action;
         HttpSession hs = hsr.getSession();
         hs.setAttribute("form/" + getClass().getName() + "/" + csrf, this);
-
     }
 
     public abstract boolean submit(PrintWriter out, HttpServletRequest req) throws GigiApiException;
@@ -34,7 +40,11 @@ public abstract class Form implements Outputable {
 
     @Override
     public void output(PrintWriter out, Language l, Map<String, Object> vars) {
-        out.println("<form method='POST'>");
+        if (action == null) {
+            out.println("<form method='POST'>");
+        } else {
+            out.println("<form method='POST' action='" + action + "'>");
+        }
         failed = false;
         outputContent(out, l, vars);
         out.print("<input type='hidden' name='" + CSRF_FIELD + "' value='");