X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2FPage.java;h=054a1e52020bf1172a095ea26a82ce5c3b4595dd;hp=f2bdbd7f7c370951ccfd02cfc9776ec3f6c86833;hb=17a15662212d973d12ed4cea3f5eaa9c0d1169ed;hpb=7be1ca08a9b8da1da284dda9aba9a6a87200319b diff --git a/src/org/cacert/gigi/pages/Page.java b/src/org/cacert/gigi/pages/Page.java index f2bdbd7f..054a1e52 100644 --- a/src/org/cacert/gigi/pages/Page.java +++ b/src/org/cacert/gigi/pages/Page.java @@ -14,6 +14,7 @@ import org.cacert.gigi.PermissionCheckable; import org.cacert.gigi.dbObjects.User; import org.cacert.gigi.localisation.Language; import org.cacert.gigi.output.template.Template; +import org.cacert.gigi.util.AuthorizationContext; /** * This class encapsulates a sub page of Gigi. A template residing nearby this @@ -57,6 +58,29 @@ public abstract class Page implements PermissionCheckable { * if output goes wrong. */ public boolean beforeTemplate(HttpServletRequest req, HttpServletResponse resp) throws IOException { + if (req.getMethod().equals("POST")) { + return beforePost(req, resp); + } + return false; + } + + /** + * This method can be overridden to execute code and do stuff before the + * default template is applied when the request is a post request and the + * default implementation of + * {@link #beforeTemplate(HttpServletRequest, HttpServletResponse)} is + * called. + * + * @param req + * the request to handle. + * @param resp + * the response to write to + * @return true, if the request is consumed and the default template should + * not be applied. + * @throws IOException + * if output goes wrong. + */ + public boolean beforePost(HttpServletRequest req, HttpServletResponse resp) throws IOException { return false; } @@ -137,8 +161,8 @@ public abstract class Page implements PermissionCheckable { } @Override - public boolean isPermitted(User u) { - return !needsLogin() || u != null; + public boolean isPermitted(AuthorizationContext ac) { + return !needsLogin() || ac != null; } }