X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Foutput%2FForm.java;fp=src%2Forg%2Fcacert%2Fgigi%2Foutput%2FForm.java;h=dd244d749afc36077bc49e55b5813268b17ddf4c;hb=13cb21e19f65dc9f8230a641edae676d88418889;hp=2ffb873171216efa91148d7798ab3b69e7029638;hpb=bb61b2ef886a4ada4e073e2b3879d9207d89350a;p=gigi.git diff --git a/src/org/cacert/gigi/output/Form.java b/src/org/cacert/gigi/output/Form.java index 2ffb8731..dd244d74 100644 --- a/src/org/cacert/gigi/output/Form.java +++ b/src/org/cacert/gigi/output/Form.java @@ -1,5 +1,6 @@ package org.cacert.gigi.output; +import java.io.IOException; import java.io.PrintWriter; import java.util.Map; @@ -45,29 +46,23 @@ public abstract class Form implements Outputable { return csrf; } - protected void checkCSRF(HttpServletRequest req) { - if (!csrf.equals(req.getParameter(CSRF_FIELD))) { - throw new CSRFError(); - } - } - - public static T getForm(HttpServletRequest req, Class target) { + public static T getForm(HttpServletRequest req, Class target) throws CSRFException { String csrf = req.getParameter(CSRF_FIELD); if (csrf == null) { - throw new CSRFError(); + throw new CSRFException(); } HttpSession hs = req.getSession(); if (hs == null) { - throw new CSRFError(); + throw new CSRFException(); } Form f = (Form) hs.getAttribute("form/" + target.getName() + "/" + csrf); if (f == null) { - throw new CSRFError(); + throw new CSRFException(); } return (T) f; } - public static class CSRFError extends Error { + public static class CSRFException extends IOException { } }